On 09/10/2026 07:48, Sho Ito wrote:
On Fri, Oct 9, 2026 at 12:32 AM Grigorev Jurij <[email protected] <mailto:[email protected]>> wrote:
While running Clang Static Analyzer through CodeChecker over PostgreSQL
18.6, we found a possible division by zero in
RememberManyTestResources():

     kind_idx = (kind_idx + 1) % nkinds;

The SQL entry point rejects negative values of nkinds but accepts zero.
If there are resources to remember, the helper then accesses kinds[0]
even though the array contains no resource kinds, and can eventually
reach the modulo operation.

Meh, ok. This is just test code, but sure, if we bother to check it at all, let's get it right.

I would also appreciate opinions on whether this test-only fix is worth
back-patching to PostgreSQL 17 and 18.  I can prepare separate
back-branch patches if needed.

Nah, thanks but not worth back-patching.

I reviewed v1 on master with assertions enabled. The test_resowner
regression test passes. Both zero-kind remember cases abort without the
patch and return the expected SQL error with it. I found no blocking issues with this test-code fix.
Thanks, I've pushed the code change. Thanks for the tests, they were nice to demonstrate the problem, but I didn't include them as these are just test functions anyway. We don't need tests for tests.

- Heikki



Reply via email to