postgres/src
Tom Lane a4930e7ca2 Fix PGLC_localeconv() to handle errors better.
The code was intentionally not very careful about leaking strdup'd
strings in case of an error.  That was forgivable probably, but it
also failed to notice strdup() failures, which could lead to subsequent
null-pointer-dereference crashes, since many callers unsurprisingly
didn't check for null pointers in the struct lconv fields.  An even
worse problem is that it could throw error while we were setlocale'd
to a non-C locale, causing unwanted behavior in subsequent libc calls.

Rewrite to ensure that we cannot throw elog(ERROR) until after we've
restored the previous locale settings, or at least attempted to.
(I'm sorely tempted to make restore failure be a FATAL error, but
will refrain for the moment.)  Having done that, it's not much more
work to ensure that we clean up strdup'd storage on the way out, too.

This code is substantially the same in all supported branches, so
back-patch all the way.

Michael Paquier and Tom Lane

Discussion: <CAB7nPqRMbGqa_mesopcn4MPyTs34eqtVEK7ELYxvvV=oqS00YA@mail.gmail.com>
2016-11-21 18:21:55 -05:00
..
backend Fix PGLC_localeconv() to handle errors better. 2016-11-21 18:21:55 -05:00
bin Clean up pg_dump tests, re-enable BLOB testing 2016-11-18 14:21:33 -05:00
common Rename "pg_xlog" directory to "pg_wal". 2016-10-20 11:32:18 -04:00
fe_utils Teach appendShellString() to not quote strings containing "-". 2016-09-06 14:53:31 -04:00
include Add pg_sequences view 2016-11-18 14:59:03 -05:00
interfaces Allow DOS-style line endings in ~/.pgpass files. 2016-11-15 16:17:19 -05:00
makefiles Provide NO_INSTALLCHECK option for pgxs. 2016-11-14 14:53:07 -08:00
pl Check that result tupdesc has exactly 1 column in return_next scalar case. 2016-11-15 16:48:19 -05:00
port pgwin32_is_junction's argument should be "const char *" not "char *". 2016-11-05 11:14:10 -04:00
template Remove "sco" and "unixware" ports. 2016-10-11 11:26:04 -04:00
test Prevent multicolumn expansion of "foo.*" in an UPDATE source expression. 2016-11-20 14:26:19 -05:00
timezone More zic cleanup. 2016-11-06 10:45:58 -05:00
tools Change qr/foo$/m to qr/foo\n/m, for Perl 5.8.8. 2016-11-07 20:27:30 -05:00
tutorial Update copyright for 2016 2016-01-02 13:33:40 -05:00
.gitignore
bcc32.mak
DEVELOPERS
Makefile Install TAP test infrastructure so it's available for extension testing. 2016-09-23 15:50:00 -04:00
Makefile.global.in Allow individual TAP tests to be run via PROVE_TESTS 2016-11-14 10:00:41 -05:00
Makefile.shlib Remove "sco" and "unixware" ports. 2016-10-11 11:26:04 -04:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00
win32.mak