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-0001r4-6N@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 ------ master Details ------- http://git.postgresql.org/pg/commitdiff/09ac603c36d1c865df68e5abd9dab04bd0fa5e48 Modified Files -------------- contrib/oid2name/oid2name.c | 38 +++++++++++++++++++++++++---------- 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/scripts/common.c | 3 ++ src/port/dirmod.c | 12 +++++++++- 11 files changed, 85 insertions(+), 22 deletions(-)
В списке pgsql-committers по дате отправления: