cJSON icon indicating copy to clipboard operation
cJSON copied to clipboard

Function print() de-allocate memory before return

Open acpie360 opened this issue 1 year ago • 1 comments

I am new to cJSON and I have a question about the function print(). This function returns an (unsigned char *) pointer that points to the print buffer that was allocated from the heap. The buffer is de-allocated before the function returns to a caller. Is this safe? I mean the caller could call another function that uses heap, and that could trash the print buffer since buffer is already released back to the heap.

acpie360 avatar Aug 01 '22 21:08 acpie360

Never mind, my mistake, I didn't read the code correctly.

acpie360 avatar Aug 01 '22 22:08 acpie360