]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix exception safety bug in typcache.c.
authorThomas Munro <tmunro@postgresql.org>
Wed, 13 Sep 2023 02:32:24 +0000 (14:32 +1200)
committerThomas Munro <tmunro@postgresql.org>
Wed, 13 Sep 2023 03:06:07 +0000 (15:06 +1200)
commitf899c7f1eae43a95ae5d221e754283d8fcfe8bc1
treef042fe8d8e9073dee302ece3afe74d7c116f7f35
parent3f7b7d9df2dc7aa14add615c7af8fbc1092509b9
Fix exception safety bug in typcache.c.

If an out-of-memory error was thrown at an unfortunate time,
ensure_record_cache_typmod_slot_exists() could leak memory and leave
behind a global state that produced an infinite loop on the next call.

Fix by merging RecordCacheArray and RecordIdentifierArray into a single
array.  With only one allocation or re-allocation, there is no
intermediate state.

Back-patch to all supported releases.

Reported-by: "James Pang (chaolpan)" <chaolpan@cisco.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/PH0PR11MB519113E738814BDDA702EDADD6EFA%40PH0PR11MB5191.namprd11.prod.outlook.com
src/backend/utils/cache/typcache.c
src/tools/pgindent/typedefs.list