DaveGamble / cJSON

Ultralightweight JSON parser in ANSI C
MIT License
10.68k stars 3.21k forks source link

Fix #881, check overlap before calling strcpy in cJSON_SetValuestring #885

Closed vwvw closed 1 month ago

vwvw commented 1 month ago

Add a check to be sure that the string don't overlap to avoid issues with strcpy. Fixes #881

All the credit goes to @tregua87

PeterAlfredLee commented 1 month ago

LGTM It will be appreciated if you can also add some tests.

vwvw commented 1 month ago

Added a test, let me know how it looks.

Alanscut commented 1 month ago

Valgrind reports. Looks you forgot about the memory free in tests.

vwvw commented 1 month ago

Pushed the necessary fix to make valgrind happy again!