-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
cJSON_InitHooks will reset the three global hook functions to malloc, free, and realloc. But, just a few lines above the hooks are initialized to internal_malloc, internal_free, and internal_realloc.
If a user program were to call cJSON_InitHooks(NULL), then the three global hook functions will not be reset to their original values, but to this potentially incorrect set of values.
I should also point out that when cJSON_InitHooks is used to set the allocate and deallocate hooks, then if the supplied value for either of those is NULL, the function will set the corresponding hook to malloc or free rather than their internal_ forms.
BTW, there is no way to set the reallocate hook to anything except realloc (should be internal_realloc) or NULL. Would be nice to be able to set this to some custom function.