From 8636d90821f9656c62e92e78d93a380fc00fc0f7 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Fri, 9 Dec 2016 10:51:10 +0100 Subject: Avoid unchecked malloc Closes #471 --- sds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sds.c b/sds.c index b31ccf2..923ffd8 100644 --- a/sds.c +++ b/sds.c @@ -89,9 +89,9 @@ sds sdsnewlen(const void *init, size_t initlen) { unsigned char *fp; /* flags pointer. */ sh = s_malloc(hdrlen+initlen+1); + if (sh == NULL) return NULL; if (!init) memset(sh, 0, hdrlen+initlen+1); - if (sh == NULL) return NULL; s = (char*)sh+hdrlen; fp = ((unsigned char*)s)-1; switch(type) { -- cgit v1.2.3