pgsql: Work around unportable behavior of malloc(0) and realloc(NULL, 0
От | Tom Lane |
---|---|
Тема | pgsql: Work around unportable behavior of malloc(0) and realloc(NULL, 0 |
Дата | |
Msg-id | E1TJA5K-0001r6-7k@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
Work around unportable behavior of malloc(0) and realloc(NULL, 0). On some platforms these functions return NULL, rather than the more common practice of returning a pointer to a zero-sized block of memory. Hack our various wrapper functions to hide the difference by substituting a size request of 1. This is probably not so important for the callers, who should never touch the block anyway if they asked for size 0 --- but it's important for the wrapper functions themselves, which mistakenly treated the NULL result as an out-of-memory failure. This broke at least pg_dump for the case of no user-defined aggregates, as per report from Matthew Carrington. Back-patch to 9.2 to fix the pg_dump issue. Given the lack of previous complaints, it seems likely that there is no live bug in previous releases, even though some of these functions were in place before that. Branch ------ REL9_2_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/689d99306a1838728075928fcc61ca3ffc112384 Modified Files -------------- contrib/oid2name/oid2name.c | 80 +++++++++++++++++++++-------------- contrib/pg_upgrade/util.c | 24 +++++++---- contrib/pgbench/pgbench.c | 6 +++ src/backend/utils/misc/guc.c | 6 +++ src/bin/initdb/initdb.c | 3 + src/bin/pg_basebackup/streamutil.c | 3 + src/bin/pg_ctl/pg_ctl.c | 3 + src/bin/pg_dump/dumpmem.c | 6 +++ src/bin/psql/common.c | 3 + src/bin/psql/print.c | 3 + src/port/dirmod.c | 12 ++++- 11 files changed, 106 insertions(+), 43 deletions(-)
В списке pgsql-committers по дате отправления: