Check for 0 size in xreallocarray - sacc - sacc(omys), simple console gopher cl… | |
git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65… | |
Log | |
Files | |
Refs | |
Tags | |
LICENSE | |
--- | |
commit 1eb587973e37752fdbd96dae505ba298d813dce5 | |
parent 2adf2ce8ca208d31ae754065bbd35e0672a50610 | |
Author: Quentin Rameau <[email protected]> | |
Date: Fri, 23 Jun 2017 20:50:43 +0200 | |
Check for 0 size in xreallocarray | |
Diffstat: | |
M sacc.c | 4 ++++ | |
1 file changed, 4 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/sacc.c b/sacc.c | |
@@ -50,6 +50,10 @@ xreallocarray(void *m, const size_t n, const size_t s) | |
{ | |
void *nm; | |
+ if (n == 0 || s == 0) { | |
+ free(m); | |
+ return NULL; | |
+ } | |
if (s && n > (size_t)-1/s) | |
die("realloc: overflow"); | |
if (!(nm = realloc(m, n * s))) |