diff --git a/CMakeLists.txt b/CMakeLists.txt index c18b84f6e3b3fe9d3551ab0babe58468a8fdded7_Q01ha2VMaXN0cy50eHQ=..81c54b482c0c88889ca127b37c62b008a4c78ef3_Q01ha2VMaXN0cy50eHQ= 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ set(PROJECT_VERSION_MAJOR 1) set(PROJECT_VERSION_MINOR 7) -set(PROJECT_VERSION_PATCH 11) +set(PROJECT_VERSION_PATCH 12) set(CJSON_VERSION_SO 1) set(CJSON_UTILS_VERSION_SO 1) set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") diff --git a/Makefile b/Makefile index c18b84f6e3b3fe9d3551ab0babe58468a8fdded7_TWFrZWZpbGU=..81c54b482c0c88889ca127b37c62b008a4c78ef3_TWFrZWZpbGU= 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ LDLIBS = -lm -LIBVERSION = 1.7.11 +LIBVERSION = 1.7.12 CJSON_SOVERSION = 1 UTILS_SOVERSION = 1 diff --git a/cJSON.c b/cJSON.c index c18b84f6e3b3fe9d3551ab0babe58468a8fdded7_Y0pTT04uYw==..81c54b482c0c88889ca127b37c62b008a4c78ef3_Y0pTT04uYw== 100644 --- a/cJSON.c +++ b/cJSON.c @@ -88,7 +88,7 @@ } /* This is a safeguard to prevent copy-pasters from using incompatible C and header files */ -#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 11) +#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 12) #error cJSON.h and cJSON.c have different versions. Make sure that both have the same. #endif @@ -519,7 +519,7 @@ } } - /* sprintf failed or buffer overrun occured */ + /* sprintf failed or buffer overrun occurred */ if ((length < 0) || (length > (int)(sizeof(number_buffer) - 1))) { return false; @@ -1570,7 +1570,7 @@ buffer_skip_whitespace(input_buffer); if (!parse_string(current_item, input_buffer)) { - goto fail; /* faile to parse name */ + goto fail; /* failed to parse name */ } buffer_skip_whitespace(input_buffer); @@ -2678,7 +2678,7 @@ *output += static_strlen("\""); - for (; (*input)[0] != '\0'; ++(*input), ++(*output)) { + for (; (*input)[0] != '\0'; (void)++(*input), ++(*output)) { (*output)[0] = (*input)[0]; if ((*input)[0] == '\"') { @@ -2722,6 +2722,8 @@ else if (json[1] == '*') { skip_multiline_comment(&json); + } else { + json++; } break; diff --git a/cJSON.h b/cJSON.h index c18b84f6e3b3fe9d3551ab0babe58468a8fdded7_Y0pTT04uaA==..81c54b482c0c88889ca127b37c62b008a4c78ef3_Y0pTT04uaA== 100644 --- a/cJSON.h +++ b/cJSON.h @@ -81,7 +81,7 @@ /* project version */ #define CJSON_VERSION_MAJOR 1 #define CJSON_VERSION_MINOR 7 -#define CJSON_VERSION_PATCH 11 +#define CJSON_VERSION_PATCH 12 #include <stddef.h> diff --git a/cJSON_Utils.c b/cJSON_Utils.c index c18b84f6e3b3fe9d3551ab0babe58468a8fdded7_Y0pTT05fVXRpbHMuYw==..81c54b482c0c88889ca127b37c62b008a4c78ef3_Y0pTT05fVXRpbHMuYw== 100644 --- a/cJSON_Utils.c +++ b/cJSON_Utils.c @@ -50,4 +50,7 @@ #include "cJSON_Utils.h" /* define our own boolean type */ +#ifdef true +#undef true +#endif #define true ((cJSON_bool)1) @@ -53,4 +56,8 @@ #define true ((cJSON_bool)1) + +#ifdef false +#undef false +#endif #define false ((cJSON_bool)0) static unsigned char* cJSONUtils_strdup(const unsigned char* const string) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c18b84f6e3b3fe9d3551ab0babe58468a8fdded7_dGVzdHMvQ01ha2VMaXN0cy50eHQ=..81c54b482c0c88889ca127b37c62b008a4c78ef3_dGVzdHMvQ01ha2VMaXN0cy50eHQ= 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -102,6 +102,9 @@ foreach (cjson_utils_test ${cjson_utils_tests}) add_executable("${cjson_utils_test}" "${cjson_utils_test}.c") target_link_libraries("${cjson_utils_test}" "${CJSON_LIB}" "${CJSON_UTILS_LIB}" unity) + if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + target_sources(${cjson_utils_test} PRIVATE unity_setup.c) + endif() if(MEMORYCHECK_COMMAND) add_test(NAME "${cjson_utils_test}" COMMAND "${MEMORYCHECK_COMMAND}" ${MEMORYCHECK_COMMAND_OPTIONS} "${CMAKE_CURRENT_BINARY_DIR}/${cjson_utils_test}") diff --git a/tests/minify_tests.c b/tests/minify_tests.c index c18b84f6e3b3fe9d3551ab0babe58468a8fdded7_dGVzdHMvbWluaWZ5X3Rlc3RzLmM=..81c54b482c0c88889ca127b37c62b008a4c78ef3_dGVzdHMvbWluaWZ5X3Rlc3RzLmM= 100644 --- a/tests/minify_tests.c +++ b/tests/minify_tests.c @@ -152,6 +152,12 @@ 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) { UNITY_BEGIN(); @@ -162,6 +168,7 @@ RUN_TEST(cjson_minify_should_remove_multiline_comments); RUN_TEST(cjson_minify_should_remove_spaces); RUN_TEST(cjson_minify_should_not_modify_strings); + RUN_TEST(cjson_minify_should_not_loop_infinitely); return UNITY_END(); }