Avoid multiple free_struct_lconv() calls on same data.
authorTom Lane
Mon, 29 Feb 2016 04:39:20 +0000 (23:39 -0500)
committerTom Lane
Mon, 29 Feb 2016 04:40:04 +0000 (23:40 -0500)
commit2d43c45e9d84d711a616d2fca7eb1b040ac5ddaf
tree8693daf0bef2e89562bb9abad10f75f66329fb7a
parent573cffc7a057f3147c23ea4d30a14c3e731a977a
Avoid multiple free_struct_lconv() calls on same data.

A failure partway through PGLC_localeconv() led to a situation where
the next call would call free_struct_lconv() a second time, leading
to free() on already-freed strings, typically leading to a core dump.
Add a flag to remember whether we need to do that.

Per report from Thom Brown.  His example case only provokes the failure
as far back as 9.4, but nonetheless this code is obviously broken, so
back-patch to all supported branches.
src/backend/utils/adt/pg_locale.c