tCheck for 0 size in xreallocarray - sacc - sacc (saccomys): simple gopher client.
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
DIR commit c56f01fe41a122aa6cc8efc59b49b7bda29b18b3
DIR parent 2adf2ce8ca208d31ae754065bbd35e0672a50610
HTML Author: Quentin Rameau <quinq@fifth.space>
Date: Fri, 23 Jun 2017 20:50:43 +0200
Check for 0 size in xreallocarray
Diffstat:
sacc.c | 4 ++++
1 file changed, 4 insertions(+), 0 deletions(-)
---
DIR diff --git a/sacc.c b/sacc.c
t@@ -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)))