pgsql: Fix exception safety bug in typcache.c.

From: Thomas Munro <tmunro(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix exception safety bug in typcache.c.
Date: 2023-09-13 03:09:43
Message-ID: E1qgGG6-003Ze7-S7@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)cisco(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Discussion: https://postgr.es/m/PH0PR11MB519113E738814BDDA702EDADD6EFA%40PH0PR11MB5191.namprd11.prod.outlook.com

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f899c7f1eae43a95ae5d221e754283d8fcfe8bc1

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

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2023-09-13 03:09:57 pgsql: Fix exception safety bug in typcache.c.
Previous Message Thomas Munro 2023-09-13 03:09:34 pgsql: Fix exception safety bug in typcache.c.