Ver código fonte

handle null pointers: cJSON_Minify

Max Bruckner 8 anos atrás
pai
commit
24ea388dcf
1 arquivos alterados com 6 adições e 0 exclusões
  1. 6 0
      cJSON.c

+ 6 - 0
cJSON.c

@@ -2390,6 +2390,12 @@ fail:
 CJSON_PUBLIC(void) cJSON_Minify(char *json)
 CJSON_PUBLIC(void) cJSON_Minify(char *json)
 {
 {
     unsigned char *into = (unsigned char*)json;
     unsigned char *into = (unsigned char*)json;
+
+    if (json == NULL)
+    {
+        return;
+    }
+
     while (*json)
     while (*json)
     {
     {
         if (*json == ' ')
         if (*json == ' ')