pgsql: Fix exception safety bug in typcache.c. - Mailing list pgsql-committers

From Thomas Munro
Subject pgsql: Fix exception safety bug in typcache.c.
Date
Msg-id E1qgGFx-003ZdW-MT@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3acd0599bd8e18ae831d1cc86b687453fdbd424a

Modified Files
--------------
src/backend/utils/cache/typcache.c | 48 +++++++++++++++++++++-----------------
src/tools/pgindent/typedefs.list   |  1 +
2 files changed, 28 insertions(+), 21 deletions(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: Switch psql's TAP test for query cancellation to use IPC::Run::s
Next
From: Thomas Munro
Date:
Subject: pgsql: Fix exception safety bug in typcache.c.