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

Started by PG Bug reporting formover 1 year ago1 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 18786
Logged by: Daniel Elishakov
Email address: dan-eli@mail.ru
PostgreSQL version: 16.6
Operating system: ubuntu 20.04
Description:

I suggest the following patch to fix this issue

@@ -1872,7 +1872,7 @@ ExtendBufferedRelShared(BufferManagerRelation bmr,
         * Note that another backend might have extended the relation by the
time
         * we get the lock.
         */
-       if (!(flags & EB_SKIP_EXTENSION_LOCK))
+       if (!(flags & EB_SKIP_EXTENSION_LOCK) && bmr.rel != NULL)
        {
                LockRelationForExtension(bmr.rel, ExclusiveLock);
                if (bmr.rel)
the problem is the same as in bug-report #18785