aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/guc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/misc/guc.c')
-rw-r--r--src/backend/utils/misc/guc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 48652b21ea4..6b202e04256 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -3358,6 +3358,9 @@ guc_malloc(int elevel, size_t size)
{
void *data;
+ /* Avoid unportable behavior of malloc(0) */
+ if (size == 0)
+ size = 1;
data = malloc(size);
if (data == NULL)
ereport(elevel,
@@ -3371,6 +3374,9 @@ guc_realloc(int elevel, void *old, size_t size)
{
void *data;
+ /* Avoid unportable behavior of realloc(NULL, 0) */
+ if (old == NULL && size == 0)
+ size = 1;
data = realloc(old, size);
if (data == NULL)
ereport(elevel,