jsonapi: fix memory leakage during OOM error recovery.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 75240f65e700d7d157be27653c70fe75108f25c1
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2024-09-23T16:30:51Z
Releases: 18.0
jsonapi: fix memory leakage during OOM error recovery.

Coverity pointed out that inc_lex_level() would leak memory
(not to mention corrupt the pstack data structure) if some
but not all of its three REALLOC's failed.  To fix, store
successfully-updated pointers back into the pstack struct
immediately.

Oversight in 0785d1b8b, so no need for back-patch.

Files

PathChange+/−
src/common/jsonapi.c modified +14 −5