mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Fix infinite loop in cJSON_Minify
This commit is contained in:
parent
465352fb99
commit
08d2bc766a
2
cJSON.c
2
cJSON.c
@ -2717,6 +2717,8 @@ CJSON_PUBLIC(void) cJSON_Minify(char *json)
|
|||||||
else if (json[1] == '*')
|
else if (json[1] == '*')
|
||||||
{
|
{
|
||||||
skip_multiline_comment(&json);
|
skip_multiline_comment(&json);
|
||||||
|
} else {
|
||||||
|
json++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -152,6 +152,12 @@ static void cjson_minify_should_minify_json(void) {
|
|||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cjson_minify_should_not_loop_infinitely(void) {
|
||||||
|
char string[] = { '8', ' ', '/', ' ', '5', '\n', '\0' };
|
||||||
|
/* this should not be an infinite loop */
|
||||||
|
cJSON_Minify(string);
|
||||||
|
}
|
||||||
|
|
||||||
int CJSON_CDECL main(void)
|
int CJSON_CDECL main(void)
|
||||||
{
|
{
|
||||||
UNITY_BEGIN();
|
UNITY_BEGIN();
|
||||||
@ -162,6 +168,7 @@ int CJSON_CDECL main(void)
|
|||||||
RUN_TEST(cjson_minify_should_remove_multiline_comments);
|
RUN_TEST(cjson_minify_should_remove_multiline_comments);
|
||||||
RUN_TEST(cjson_minify_should_remove_spaces);
|
RUN_TEST(cjson_minify_should_remove_spaces);
|
||||||
RUN_TEST(cjson_minify_should_not_modify_strings);
|
RUN_TEST(cjson_minify_should_not_modify_strings);
|
||||||
|
RUN_TEST(cjson_minify_should_not_loop_infinitely);
|
||||||
|
|
||||||
return UNITY_END();
|
return UNITY_END();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user