Skip to content

Commit 3983105

Browse files
committed
try a realloc patch
1 parent 546449b commit 3983105

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/kplot/reallocarray.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,10 @@ reallocarray(void *optr, size_t nmemb, size_t size)
3535
errno = ENOMEM;
3636
return NULL;
3737
}
38-
return realloc(optr, size * nmemb);
38+
39+
// some realloc() on some platforms fail with realloc(0)
40+
if (optr)
41+
return realloc(optr, size * nmemb);
42+
else
43+
return malloc(size * nmemb);
3944
}

0 commit comments

Comments
 (0)