]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix various instances of undefined behavior
authorJohn Naylor <john.naylor@postgresql.org>
Wed, 4 Feb 2026 10:55:49 +0000 (17:55 +0700)
committerJohn Naylor <john.naylor@postgresql.org>
Wed, 4 Feb 2026 11:09:35 +0000 (18:09 +0700)
commit176dffdf7d2a0ea2615c4e390a2ab7e69d14f90f
treec6ffd232492a37728557d05a9197ecd02e857abd
parent084e42bc7109673e46527b0a0f284edf539c3285
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 <exclusion@gmail.com>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/777bd201-6e3a-4da0-a922-4ea9de46a3ee@gmail.com
Backpatch-through: 14
contrib/pg_trgm/trgm_gist.c
src/backend/access/heap/heaptoast.c
src/backend/utils/adt/multirangetypes.c
src/backend/utils/sort/sharedtuplestore.c