]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tolerate NULL in strdup(). Patch by shawn (sth0r2046 [at] gmail.com).
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 27 Apr 2014 15:59:19 +0000 (17:59 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 27 Apr 2014 15:59:19 +0000 (17:59 +0200)
lib/gnutls_mem.c

index 8c244207708ebd610108341dbbcb5c4ad74ac915..d2da8b0ffe9390f56eb7cc3ce46f9c2c52665f3c 100644 (file)
@@ -63,9 +63,14 @@ void *gnutls_realloc_fast(void *ptr, size_t size)
 
 char *_gnutls_strdup(const char *str)
 {
-       size_t siz = strlen(str) + 1;
+       size_t siz;
        char *ret;
 
+       if(unlikely(!str))
+               return NULL;
+
+       siz = strlen(str) + 1;
+
        ret = gnutls_malloc(siz);
        if (ret != NULL)
                memcpy(ret, str, siz);