Don't leak malloc'd strings when a GUC setting is rejected.

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

Commit: fc552f8680a79d602beae230615ffe8ed236cc43
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2021-03-19T02:09:41Z
Releases: 12.7
Don't leak malloc'd strings when a GUC setting is rejected.

Because guc.c prefers to keep all its string values in malloc'd
not palloc'd storage, it has to be more careful than usual to
avoid leaks.  Error exits out of string GUC hook checks failed
to clear the proposed value string, and error exits out of
ProcessGUCArray() failed to clear the malloc'd results of
ParseLongOption().

Found via valgrind testing.
This problem is ancient, so back-patch to all supported branches.

Discussion: https://postgr.es/m/3816764.1616104288@sss.pgh.pa.us

Files

PathChange+/−
src/backend/utils/misc/guc.c modified +47 −24

Discussion