diff options
Diffstat (limited to 'src/bin/pg_dump/dumpmem.c')
-rw-r--r-- | src/bin/pg_dump/dumpmem.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bin/pg_dump/dumpmem.c b/src/bin/pg_dump/dumpmem.c index 3ef10307bc5..cadc89d4447 100644 --- a/src/bin/pg_dump/dumpmem.c +++ b/src/bin/pg_dump/dumpmem.c @@ -42,6 +42,9 @@ pg_malloc(size_t size) { void *tmp; + /* Avoid unportable behavior of malloc(0) */ + if (size == 0) + size = 1; tmp = malloc(size); if (!tmp) exit_horribly(NULL, "out of memory\n"); @@ -64,6 +67,9 @@ pg_realloc(void *ptr, size_t size) { void *tmp; + /* Avoid unportable behavior of realloc(NULL, 0) */ + if (ptr == NULL && size == 0) + size = 1; tmp = realloc(ptr, size); if (!tmp) exit_horribly(NULL, "out of memory\n"); |