But WHERE did the "number" variable get produced, as in: what does it actually point to? Something allocated with malloc(), or something else? Show us the code that calls add_number().
You do realize that you are not writing your "number" content into the memory allocated in the second code-snippet I quoted, but rather just overwriting the pointer itself.
If you EVER free something that wasn't allocated by malloc/realloc, then you will get undefined behaviour - such as what you are seeing right now?
--
Mats


