@@ -471,6 +471,19 @@ static void cjson_functions_should_not_crash_with_null_pointers(void)
471
471
cJSON_Delete (item );
472
472
}
473
473
474
+ static void cjson_set_valuestring_should_return_null_if_strings_overlap (void )
475
+ {
476
+ cJSON * obj , * obj_dup ;
477
+ char * str ;
478
+
479
+ obj = cJSON_Parse ("\"fooz\"" );
480
+ obj_dup = cJSON_Duplicate (obj , 1 );
481
+
482
+ str = cJSON_SetValuestring (obj_dup , "beeez" );
483
+ cJSON_SetValuestring (obj_dup , str );
484
+ cJSON_SetValuestring (obj_dup , ++ str );
485
+ }
486
+
474
487
static void * CJSON_CDECL failing_realloc (void * pointer , size_t size )
475
488
{
476
489
(void )size ;
@@ -765,6 +778,7 @@ int CJSON_CDECL main(void)
765
778
RUN_TEST (cjson_replace_item_via_pointer_should_replace_items );
766
779
RUN_TEST (cjson_replace_item_in_object_should_preserve_name );
767
780
RUN_TEST (cjson_functions_should_not_crash_with_null_pointers );
781
+ RUN_TEST (cjson_set_valuestring_should_return_null_if_strings_overlap );
768
782
RUN_TEST (ensure_should_fail_on_failed_realloc );
769
783
RUN_TEST (skip_utf8_bom_should_skip_bom );
770
784
RUN_TEST (skip_utf8_bom_should_not_skip_bom_if_not_at_beginning );
0 commit comments