postgresql/src
John Naylor 1662cd0cb7 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
2026-02-04 17:59:18 +07:00
..
backend Fix various instances of undefined behavior 2026-02-04 17:59:18 +07:00
bin pg_resetwal: Fix incorrect error message related to pg_wal/summaries/ 2026-02-04 16:38:12 +09:00
common With GB18030, prevent SIGSEGV from reading past end of allocation. 2025-05-05 04:52:07 -07:00
fe_utils In fmtIdEnc(), handle failure of enlargePQExpBuffer(). 2025-02-16 12:46:35 -05:00
include Fix build inconsistency due to the generation of wait-event code 2026-02-02 08:03:02 +09:00
interfaces Fix printf format string warning on MinGW. 2025-12-21 21:28:12 +13:00
makefiles Optimize pg_popcount() with AVX-512 instructions. 2024-04-06 21:56:23 -05:00
pl Translation updates 2025-11-10 13:02:28 +01:00
port Fix O_CLOEXEC flag handling in Windows port. 2025-12-10 09:10:31 +13:00
template Remove AIX support 2024-02-28 15:17:23 +04:00
test Improve guards against false regex matches in BackgroundPsql.pm. 2026-01-30 14:59:25 -05:00
timezone Update time zone data files to tzdata release 2025c. 2026-01-18 14:54:54 -05:00
tools For inplace update, send nontransactional invalidations. 2025-12-16 16:13:54 -08:00
tutorial Update copyright for 2024 2024-01-03 20:49:05 -05:00
.gitignore
DEVELOPERS
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.global.in Don't put library-supplied -L/-I switches before user-supplied ones. 2025-07-29 15:17:41 -04:00
Makefile.shlib Remove AIX support 2024-02-28 15:17:23 +04:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
nls-global.mk Fix update-po for the PGXS case 2025-10-16 20:21:05 +02:00