]> 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 10:59:18 +0000 (17:59 +0700)
commit73ac2b37401d7aa910ebd81795bb0f4faf0eaab3
tree071583f2d512cca11c9ab4cb0a72f9633d727d38
parent6548e4a10d1807b04bdb9370b110204821b7506c
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