summaryrefslogtreecommitdiff
path: root/contrib/pgbench/pgbench.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/pgbench/pgbench.c')
-rw-r--r--contrib/pgbench/pgbench.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index 509472262bc..a669cf406ba 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -299,6 +299,9 @@ pg_malloc(size_t size)
{
void *result;
+ /* Avoid unportable behavior of malloc(0) */
+ if (size == 0)
+ size = 1;
result = malloc(size);
if (!result)
{
@@ -313,6 +316,9 @@ pg_realloc(void *ptr, size_t size)
{
void *result;
+ /* Avoid unportable behavior of realloc(NULL, 0) */
+ if (ptr == NULL && size == 0)
+ size = 1;
result = realloc(ptr, size);
if (!result)
{