tCheck for 0 size in xreallocarray - sacc - sacc(omys), simple console gopher client (mirror) HTML git clone https://git.parazyd.org/sacc DIR Log DIR Files DIR Refs DIR LICENSE --- DIR commit 1eb587973e37752fdbd96dae505ba298d813dce5 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: M 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)))