@@ -96,19 +96,19 @@ CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
96
96
return (const char * ) (global_error .json + global_error .position );
97
97
}
98
98
99
- CJSON_PUBLIC (char * ) cJSON_GetStringValue (const cJSON * const item )
99
+ CJSON_PUBLIC (char * ) cJSON_GetStringValue (const cJSON * const item )
100
100
{
101
- if (!cJSON_IsString (item ))
101
+ if (!cJSON_IsString (item ))
102
102
{
103
103
return NULL ;
104
104
}
105
105
106
106
return item -> valuestring ;
107
107
}
108
108
109
- CJSON_PUBLIC (double ) cJSON_GetNumberValue (const cJSON * const item )
109
+ CJSON_PUBLIC (double ) cJSON_GetNumberValue (const cJSON * const item )
110
110
{
111
- if (!cJSON_IsNumber (item ))
111
+ if (!cJSON_IsNumber (item ))
112
112
{
113
113
return (double ) NAN ;
114
114
}
@@ -511,7 +511,7 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)
511
511
512
512
return NULL ;
513
513
}
514
-
514
+
515
515
memcpy (newbuffer , p -> buffer , p -> offset + 1 );
516
516
p -> hooks .deallocate (p -> buffer );
517
517
}
@@ -1107,7 +1107,7 @@ CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer
1107
1107
}
1108
1108
1109
1109
buffer .content = (const unsigned char * )value ;
1110
- buffer .length = buffer_length ;
1110
+ buffer .length = buffer_length ;
1111
1111
buffer .offset = 0 ;
1112
1112
buffer .hooks = global_hooks ;
1113
1113
@@ -2361,6 +2361,11 @@ static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSO
2361
2361
cJSON_free (replacement -> string );
2362
2362
}
2363
2363
replacement -> string = (char * )cJSON_strdup ((const unsigned char * )string , & global_hooks );
2364
+ if (replacement -> string == NULL )
2365
+ {
2366
+ return false;
2367
+ }
2368
+
2364
2369
replacement -> type &= ~cJSON_StringIsConst ;
2365
2370
2366
2371
return cJSON_ReplaceItemViaPointer (object , get_object_item (object , string , case_sensitive ), replacement );
@@ -2693,7 +2698,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int co
2693
2698
if (a && a -> child ) {
2694
2699
a -> child -> prev = n ;
2695
2700
}
2696
-
2701
+
2697
2702
return a ;
2698
2703
}
2699
2704
0 commit comments