Re: [PATCH] bms_prev_member() can read beyond the end of the array of allocated words - Mailing list pgsql-hackers

From David Rowley
Subject Re: [PATCH] bms_prev_member() can read beyond the end of the array of allocated words
Date
Msg-id CAApHDvpi6LgxtoV=XhTfbsXYa2gULy=JoCxen8s_OszFhAO7bA@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] bms_prev_member() can read beyond the end of the array of allocated words  (Greg Burd <greg@burd.me>)
Responses Re: [PATCH] bms_prev_member() can read beyond the end of the array of allocated words
List pgsql-hackers
On Fri, 15 Aug 2025 at 03:43, Greg Burd <greg@burd.me> wrote:
> Well, that was rushed.  Apologies.

Would you be ok with adding the Assert after the "a == NULL" check?, i.e:

if (a == NULL || prevbit == 0)
    return -2;

/* Validate callers didn't give us something out of range */
Assert(prevbit <= a->nwords * BITS_PER_BITMAPWORD);

David



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCH] Silence Valgrind about SelectConfigFiles()
Next
From: Álvaro Herrera
Date:
Subject: Re: don't include tableam.h in nbtree.h