json-tutorial
json-tutorial copied to clipboard
lept_set_string(): memcpy exists potential undefined behavior
When s == NULL and len == 0, we try copy s to v->u.s.s that is undefined behavior.
The behavior is undefined if either dest or src is an invalid or null pointer.
https://github.com/miloyip/json-tutorial/blob/65c078b2bb270bfc9af50497cd1844bcff5c8214/tutorial03/leptjson.c#L183-L191
We can solve this by add if (s != NULL) before memcpy.