mirror of
https://github.com/eclipse/mosquitto.git
synced 2025-10-14 02:48:40 +08:00
dynsec: use cJSON_free to deallocate cJSON_Print result
The JSON string produced by cJSON_Print() is allocated with cJSON_malloc() and must be freed with cJSON_free(), not mosquitto_free(). Using the wrong allocator caused Mosquitto’s memory-tracking counter to underflow, leading to spurious "out of memory" errors on subsequent allocations which render the broker unusable. This change replaces mosquitto_free(json_str) with cJSON_free(json_str) in dynsec__config_save(), ensuring correct matching of allocators and eliminating the underflow bug. Signed-off-by: Jesús Fernández Manzano <jesus.fernandez@titanos.tv>
This commit is contained in:

committed by
Roger Light

parent
b99c89cfc9
commit
e1ab3908c2
@@ -629,7 +629,7 @@ void dynsec__config_save(void)
|
||||
return;
|
||||
}
|
||||
fwrite(json_str, 1, json_str_len, fptr);
|
||||
mosquitto_free(json_str);
|
||||
cJSON_free(json_str);
|
||||
fclose(fptr);
|
||||
|
||||
/* Everything is ok, so move new file over proper file */
|
||||
|
Reference in New Issue
Block a user