BUG #18849: DEREF_OF_NULL.RET Pointer '&partexprs_item.ptr_value', returned from function 'list_head' at partiti

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: pm91(dot)arapov(at)gmail(dot)com
Subject: BUG #18849: DEREF_OF_NULL.RET Pointer '&partexprs_item.ptr_value', returned from function 'list_head' at partiti
Date: 2025-03-14 09:14:19
Message-ID: 18849-4a0299b366741739@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: 18849
Logged by: Nikita
Email address: pm91(dot)arapov(at)gmail(dot)com
PostgreSQL version: 16.6
Operating system: ubuntu 20.04
Description:

In principle, if data structure is correct there will be no problems. As for
correct structure it is known that there will be a non-NULL value. However
in other places that deal with the same structure the appropriate checks are
present. So for consistency we can add such a check here as well. On other
hand if the structure is checked for correctness in other places there is no
need to check it once again. So the decision on this is not very certain.

diff --git a/src/backend/catalog/partition.c
b/src/backend/catalog/partition.c
--- a/src/backend/catalog/partition.c (revision
a49ac80219c6f28c3cf3973f797de637329952da)
+++ b/src/backend/catalog/partition.c (date 1740397337018)
@@ -283,6 +283,8 @@
}
else
{
+ if(partexprs_item == NULL)
+ return false;
/* Arbitrary expression */
Node *expr = (Node *) lfirst(partexprs_item);
Bitmapset *expr_attrs = NULL;

I suggest the following patch fixing this issue

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2025-03-14 09:16:06 BUG #18850: REDUNDANT_COMPARISON.ALWAYS_FALSE Redundant comparison
Previous Message PG Bug reporting form 2025-03-14 09:12:41 BUG #18848: DEREF_AFTER_NULL.EX.COND After having been compared to a NULL