Sfoglia il codice sorgente

cJSON_strdup: Check for NULL string

Max Bruckner 8 anni fa
parent
commit
1df987a170
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5 0
      cJSON.c

+ 5 - 0
cJSON.c

@@ -88,6 +88,11 @@ static char* cJSON_strdup(const char* str)
     size_t len = 0;
     char *copy = NULL;
 
+    if (str == NULL)
+    {
+        return NULL;
+    }
+
     len = strlen(str) + 1;
     if (!(copy = (char*)cJSON_malloc(len)))
     {