postgresql/src/backend
Tom Lane 7b86c2ac95 Improve dubious memory management in pg_newlocale_from_collation().
pg_newlocale_from_collation() used malloc() and strdup() directly,
which is generally not per backend coding style, and it didn't bother
to check for failure results, but would just SIGSEGV instead.  Also,
if one of the numerous error checks in the middle of the function
failed, the already-allocated memory would be leaked permanently.
Admittedly, it's not a lot of memory, but it could build up if this
function were called repeatedly for a bad collation.

The first two problems are easily cured by palloc'ing in TopMemoryContext
instead of calling libc directly.  We can fairly easily dodge the leakage
problem for the struct pg_locale_struct by filling in a temporary variable
and allocating permanent storage only once we reach the bottom of the
function.  It's harder to get rid of the potential leakage for ICU's copy
of the collcollate string, but at least that's only allocated after most
of the error checks; so live with that aspect.

Back-patch to v10 where this code came in, with one or another of the
ICU patches.
2017-09-20 13:52:36 -04:00
..
access Make WAL segment size configurable at initdb time. 2017-09-19 22:03:48 -07:00
bootstrap Sync process names between ps and pg_stat_activity 2017-09-20 08:59:03 -04:00
catalog Make RelationGetPartitionDispatchInfo expand depth-first. 2017-09-14 12:28:50 -04:00
commands Make ExplainOpenGroup and ExplainCloseGroup public. 2017-09-18 16:01:16 -04:00
executor Fix SQL-spec incompatibilities in new transition table feature. 2017-09-16 13:20:36 -04:00
foreign Abstract logic to allow for multiple kinds of child rels. 2017-04-03 22:41:31 -04:00
lib Fix uninitialized variable in dshash.c. 2017-09-18 17:43:37 -07:00
libpq Define LDAP_NO_ATTRS if necessary. 2017-09-13 08:22:42 -04:00
main Change pg_ctl to detect server-ready by watching status in postmaster.pid. 2017-06-28 17:31:32 -04:00
nodes Allow a partitioned table to have a default partition. 2017-09-08 17:28:04 -04:00
optimizer Fix create_lateral_join_info to handle dead relations properly. 2017-09-20 10:20:10 -04:00
parser After a MINVALUE/MAXVALUE bound, allow only more of the same. 2017-09-15 21:15:55 -04:00
po Translation updates 2017-08-07 13:55:34 -04:00
port Change pg_ctl to detect server-ready by watching status in postmaster.pid. 2017-06-28 17:31:32 -04:00
postmaster Sync process names between ps and pg_stat_activity 2017-09-20 08:59:03 -04:00
regex Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
replication Make WAL segment size configurable at initdb time. 2017-09-19 22:03:48 -07:00
rewrite Message style fixes 2017-09-11 11:21:27 -04:00
snowball Initial pgindent run with pg_bsd_indent version 2.0. 2017-06-21 14:39:04 -04:00
statistics Remove obsolete comments about functional dependencies 2017-07-26 11:40:39 -04:00
storage Add support for coordinating record typmods among parallel workers. 2017-09-14 19:59:21 -07:00
tcop Rearm statement_timeout after each executed query. 2017-09-18 19:36:44 -07:00
tsearch Make DatumGetFoo/PG_GETARG_FOO/PG_RETURN_FOO macro names more consistent. 2017-09-18 15:21:23 -04:00
utils Improve dubious memory management in pg_newlocale_from_collation(). 2017-09-20 13:52:36 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Inject $(ICU_LIBS) regardless of platform. 2017-08-20 21:22:18 -07:00
common.mk Add ICU_CFLAGS to global CPPFLAGS 2017-06-12 15:57:22 -04:00
nls.mk Translation updates 2017-05-15 12:19:54 -04:00