BUG #19065: postgresql-18.0/src/bin/pg_combinebackup/reconstruct.c:230: Array sanity check in wrong place ?

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

The following bug has been logged on the website:

Bug reference: 19065
Logged by: David Binderman
Email address: dcb314@hotmail.com
PostgreSQL version: 18.0
Operating system: fedora 42
Description:

Static analyser cppcheck said:

postgresql-18.0/src/bin/pg_combinebackup/reconstruct.c:230:18: style: Array
index 'b' is used before limits check. [arrayIndexThenCheck]

Source code is

if (sourcemap[b] == NULL && b < blocklength)

Suggest new code

if (b < blocklength && sourcemap[b] == NULL)