BUG #19066: postgresql-18.0/src/backend/optimizer/geqo/geqo_ox2.c:86: Array index check in wrong place ?

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: dcb314(at)hotmail(dot)com
Subject: BUG #19066: postgresql-18.0/src/backend/optimizer/geqo/geqo_ox2.c:86: Array index check in wrong place ?
Date: 2025-09-26 09:51:09
Message-ID: 19066-53bfa81d53f11b75@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19066
Logged by: David Binderman
Email address: dcb314(at)hotmail(dot)com
PostgreSQL version: 18.0
Operating system: fedora 42
Description:

Static analyser cppcheck says:

postgresql-18.0/src/backend/optimizer/geqo/geqo_ox2.c:86:22: style: Array
index 'j' is used before limits check. [arrayIndexThenCheck]

Source code is

while ((city_table[j].select_list == -1) && (j < num_gene))

Suggest new source code

while ((j < num_gene) && (city_table[j].select_list == -1))

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Todd Cook 2025-09-26 12:30:36 Re: Postgres: Queries are too slow after upgrading to PG17 from PG15
Previous Message PG Bug reporting form 2025-09-26 09:48:20 BUG #19065: postgresql-18.0/src/bin/pg_combinebackup/reconstruct.c:230: Array sanity check in wrong place ?