Avoid multiple free_struct_lconv() calls on same data.

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

Commit: 80c925c7b4efcd80a8c648ca94ba1fabbd2863ae
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2016-02-29T04:40:13Z
Releases: 9.4.7
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.

Files

PathChange+/−
src/backend/utils/adt/pg_locale.c modified +11 −5