memset() doesn't take NULL.
authorBen Laurie <ben@links.org>
Wed, 4 May 2016 10:45:49 +0000 (11:45 +0100)
committerBen Laurie <ben@links.org>
Sat, 7 May 2016 17:28:07 +0000 (18:28 +0100)
Reviewed-by: Emilia Käsper <emilia@openssl.org>
crypto/buffer/buffer.c

index a16f3bd..1c76d66 100644 (file)
@@ -128,7 +128,8 @@ size_t BUF_MEM_grow(BUF_MEM *str, size_t len)
         return (len);
     }
     if (str->max >= len) {
-        memset(&str->data[str->length], 0, len - str->length);
+        if (str->data != NULL)
+            memset(&str->data[str->length], 0, len - str->length);
         str->length = len;
         return (len);
     }
@@ -160,7 +161,8 @@ size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len)
     size_t n;
 
     if (str->length >= len) {
-        memset(&str->data[len], 0, str->length - len);
+        if (str->data != NULL)
+            memset(&str->data[len], 0, str->length - len);
         str->length = len;
         return (len);
     }