Don't leak malloc'd strings when a GUC setting is rejected.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 Mar 2021 02:09:41 +0000 (22:09 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 Mar 2021 02:09:41 +0000 (22:09 -0400)
commit642b0b69b0638261fe81dfd9ca3b92927496f1cb
tree472f6f15456fad29891a0d9f0b92bee69bee432e
parenteba939551afe5709d15fe7779e7771ae0c8bf830
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
src/backend/utils/misc/guc.c