Details
-
Wish
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
proton-0.8
-
None
Description
As we are running the ProtonC project on memory constrained systems, it is possible for malloc() or realloc() to return a NULL, when there is no more free heap to allocate the memory from.
Obviously, we might have a specific optimizations in the ProtonC code, which deeply minimize the amount of a total heap required, but this is not what this ticket is referring to.
In any case where there is no more free heap, or in a case where there is any other issue with the allocators, the memory allocation functions return NULL.
The ProtonC code at this state, does not check for such a situation, and it always expects the malloc() and realloc() to work and to return a valid pointer.
I would like the developers to add a specific test to each place, where memory allocation takes place, and to act upon an error properly (ideally - with a graceful closure of the connection to broker, if possible).
Also, a proper signalization path to the user's application (which runs the ProtonC client) would be a great addition.
If nothing fancy is planned, I would, at least, ask for adding the simple {{ if (x == NULL)
{ do something }; }} tests to each every place where memory allocation is handled.
Attachments
Issue Links
- is duplicated by
-
PROTON-643 Malloc result used without testing for null
- Closed