Skip to content

1.3.0

Compare
Choose a tag to compare
@FSMaxB FSMaxB released this 17 Feb 00:49
· 670 commits to master since this release

This release includes a lot of rework in the parser and includes the Cunity unit testing framework, as well as some fixes. I increased the minor version number because there were quite a lot of internal changes.

Features:

  • New type for cJSON structs: cJSON_Invalid (#108)

Fixes:

  • runtime checks for a lot of potential integer overflows
  • fix incorrect return in cJSON_PrintBuffered (cf9d57d)
  • fix several potential issues found by Coverity
  • fix potentially undefined behavior when assigning big numbers to valueint (41e2837)
    • Numbers exceeding INT_MAX or lower than INT_MIN will be explicitly assigned to valueint as INT_MAX and INT_MIN respectively (saturation on overflow).
    • fix the cJSON_SetNumberValue macro (87f7727), this slightly changes the behavior, see commit message

Introduce unit tests

Started writing unit tests with the Cunity testing framework. Currently this covers the parser functions.

Also:

Simplifications

After having unit tests for the parser function in place, I started refactoring the parser functions (as well as others) and making them easier to read and maintain.

  • Use strtod from the standard library for parsing numbers (0747669)
  • Use goto-fail in several parser functions (#100)
  • Rewrite/restructure all of the parsing functions to be easier to understand and have less code paths doing the same as another. (#109)
  • Simplify the buffer allocation strategy to always doubling the needed amount (9f6fa94)
  • Combined cJSON_AddItemToObject and cJSON_AddItemToObjectCS to one function (cf862d0)

Other changes

  • Prevent the usage of incompatible C and header versions via preprocessor directive (123bb1a)
  • Let CMake automatically detect compiler flags
  • Add new compiler flags (-Wundef, -Wswitch-default, -Wconversion, -fstack-protector-strong) (#98)
  • Change internal sizes from int to size_t (ecd5678)
  • Change internal strings from char* to unsigned char* (28b9ba4)
  • Add const in more places