BUG #18785: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: dan-eli(at)mail(dot)ru
Subject: BUG #18785: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later
Date: 2025-01-28 13:58:13
Message-ID: 18785-916b89e64ced06e1@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18785
Logged by: Daniel Elishakov
Email address: dan-eli(at)mail(dot)ru
PostgreSQL version: 16.6
Operating system: ubuntu 20.04
Description:

Hello, I suggest the following patch for this issue.

@@ -905,6 +905,8 @@ ExtendBufferedRelTo(BufferManagerRelation bmr,
bmr.smgr->smgr_cached_nblocks[fork] == InvalidBlockNumber)
&&
!smgrexists(bmr.smgr, fork))
{
+
+ Assert(bmr.rel != NULL);
LockRelationForExtension(bmr.rel, ExclusiveLock);

/* could have been closed while waiting for lock */

I think we need to check bmr.rel for NULL, because Asserts above do not
suggest bmr.rel != NULL. Moreover, it is being checked for NULL later after
being passed into function LockRelationForExtension(bmr.rel, ExclusiveLock);

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2025-01-28 14:08:55 BUG #18786: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later
Previous Message VASUKI M 2025-01-28 09:56:37 Re: BUG #18784: Bugs and BugTracking