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

PG Bug reporting form <noreply@postgresql.org>

From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: dcb314@hotmail.com
Date: 2025-09-26T09:48:20Z
Lists: pgsql-bugs
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)