Check for 0 size in xreallocarray - sacc - sacc(omys), simple console gopher client
(HTM) git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/sacc/
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) LICENSE
---
(DIR) commit 1eb587973e37752fdbd96dae505ba298d813dce5
(DIR) parent 2adf2ce8ca208d31ae754065bbd35e0672a50610
(HTM) Author: Quentin Rameau <quinq@fifth.space>
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(-)
---
(DIR) 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)))