public inbox for [email protected]  
help / color / mirror / Atom feed
pgsql: Fix various instances of undefined behavior
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix various instances of undefined behavior
@ 2026-02-04 11:09  John Naylor <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: John Naylor @ 2026-02-04 11:09 UTC (permalink / raw)
  To: [email protected]

Fix various instances of undefined behavior

Mostly this involves checking for NULL pointer before doing operations
that add a non-zero offset.

The exception is an overflow warning in heap_fetch_toast_slice(). This
was caused by unneeded parentheses forcing an expression to be
evaluated to a negative integer, which then got cast to size_t.

Per clang 21 undefined behavior sanitizer.

Backpatch to all supported versions.

Co-authored-by: Alexander Lakhin <[email protected]>
Reported-by: Alexander Lakhin <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b5e1cd2fdca1ad48982e376c0d22f468e862933c

Modified Files
--------------
contrib/pg_trgm/trgm_gist.c               | 5 ++++-
src/backend/access/heap/heaptoast.c       | 2 +-
src/backend/utils/adt/multirangetypes.c   | 5 +++--
src/backend/utils/sort/sharedtuplestore.c | 3 ++-
4 files changed, 10 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix various instances of undefined behavior
@ 2026-02-04 11:09  John Naylor <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: John Naylor @ 2026-02-04 11:09 UTC (permalink / raw)
  To: [email protected]

Fix various instances of undefined behavior

Mostly this involves checking for NULL pointer before doing operations
that add a non-zero offset.

The exception is an overflow warning in heap_fetch_toast_slice(). This
was caused by unneeded parentheses forcing an expression to be
evaluated to a negative integer, which then got cast to size_t.

Per clang 21 undefined behavior sanitizer.

Backpatch to all supported versions.

Co-authored-by: Alexander Lakhin <[email protected]>
Reported-by: Alexander Lakhin <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1662cd0cb7ae42334af17caa7dceb172b45248f7

Modified Files
--------------
contrib/pg_trgm/trgm_gist.c               | 5 ++++-
src/backend/access/heap/heaptoast.c       | 2 +-
src/backend/utils/adt/multirangetypes.c   | 5 +++--
src/backend/utils/sort/sharedtuplestore.c | 3 ++-
4 files changed, 10 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix various instances of undefined behavior
@ 2026-02-04 11:09  John Naylor <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: John Naylor @ 2026-02-04 11:09 UTC (permalink / raw)
  To: [email protected]

Fix various instances of undefined behavior

Mostly this involves checking for NULL pointer before doing operations
that add a non-zero offset.

The exception is an overflow warning in heap_fetch_toast_slice(). This
was caused by unneeded parentheses forcing an expression to be
evaluated to a negative integer, which then got cast to size_t.

Per clang 21 undefined behavior sanitizer.

Backpatch to all supported versions.

Co-authored-by: Alexander Lakhin <[email protected]>
Reported-by: Alexander Lakhin <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/73ac2b37401d7aa910ebd81795bb0f4faf0eaab3

Modified Files
--------------
contrib/pg_trgm/trgm_gist.c               | 5 ++++-
src/backend/access/heap/heaptoast.c       | 2 +-
src/backend/utils/adt/multirangetypes.c   | 5 +++--
src/backend/utils/sort/sharedtuplestore.c | 3 ++-
4 files changed, 10 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix various instances of undefined behavior
@ 2026-02-04 11:09  John Naylor <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: John Naylor @ 2026-02-04 11:09 UTC (permalink / raw)
  To: [email protected]

Fix various instances of undefined behavior

Mostly this involves checking for NULL pointer before doing operations
that add a non-zero offset.

The exception is an overflow warning in heap_fetch_toast_slice(). This
was caused by unneeded parentheses forcing an expression to be
evaluated to a negative integer, which then got cast to size_t.

Per clang 21 undefined behavior sanitizer.

Backpatch to all supported versions.

Co-authored-by: Alexander Lakhin <[email protected]>
Reported-by: Alexander Lakhin <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6b81a1c7c9057cda541401509b6dbc30a632410e

Modified Files
--------------
contrib/pg_trgm/trgm_gist.c               | 5 ++++-
src/backend/access/heap/heaptoast.c       | 2 +-
src/backend/utils/adt/multirangetypes.c   | 5 +++--
src/backend/utils/sort/sharedtuplestore.c | 3 ++-
4 files changed, 10 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix various instances of undefined behavior
@ 2026-02-04 11:09  John Naylor <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: John Naylor @ 2026-02-04 11:09 UTC (permalink / raw)
  To: [email protected]

Fix various instances of undefined behavior

Mostly this involves checking for NULL pointer before doing operations
that add a non-zero offset.

The exception is an overflow warning in heap_fetch_toast_slice(). This
was caused by unneeded parentheses forcing an expression to be
evaluated to a negative integer, which then got cast to size_t.

Per clang 21 undefined behavior sanitizer.

Backpatch to all supported versions.

Co-authored-by: Alexander Lakhin <[email protected]>
Reported-by: Alexander Lakhin <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/fc56793c9ae5b88f5c14daadf927c6d495cca39e

Modified Files
--------------
contrib/pg_trgm/trgm_gist.c               | 5 ++++-
src/backend/access/heap/heaptoast.c       | 2 +-
src/backend/utils/adt/multirangetypes.c   | 5 +++--
src/backend/utils/sort/sharedtuplestore.c | 3 ++-
4 files changed, 10 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix various instances of undefined behavior
@ 2026-02-04 11:11  John Naylor <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: John Naylor @ 2026-02-04 11:11 UTC (permalink / raw)
  To: [email protected]

Fix various instances of undefined behavior

Mostly this involves checking for NULL pointer before doing operations
that add a non-zero offset.

The exception is an overflow warning in heap_fetch_toast_slice(). This
was caused by unneeded parentheses forcing an expression to be
evaluated to a negative integer, which then got cast to size_t.

Per clang 21 undefined behavior sanitizer.

Backpatch to all supported versions.

Co-authored-by: Alexander Lakhin <[email protected]>
Reported-by: Alexander Lakhin <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/176dffdf7d2a0ea2615c4e390a2ab7e69d14f90f

Modified Files
--------------
contrib/pg_trgm/trgm_gist.c               | 5 ++++-
src/backend/access/heap/heaptoast.c       | 2 +-
src/backend/utils/adt/multirangetypes.c   | 5 +++--
src/backend/utils/sort/sharedtuplestore.c | 3 ++-
4 files changed, 10 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2026-02-04 11:11 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-02-04 11:09 pgsql: Fix various instances of undefined behavior John Naylor <[email protected]>
2026-02-04 11:09 pgsql: Fix various instances of undefined behavior John Naylor <[email protected]>
2026-02-04 11:09 pgsql: Fix various instances of undefined behavior John Naylor <[email protected]>
2026-02-04 11:09 pgsql: Fix various instances of undefined behavior John Naylor <[email protected]>
2026-02-04 11:09 pgsql: Fix various instances of undefined behavior John Naylor <[email protected]>
2026-02-04 11:11 pgsql: Fix various instances of undefined behavior John Naylor <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox