[cfe-dev] What memory-allocating functions should we check for leaks?
<Alexander G. Riccio> via cfe-dev
cfe-dev at lists.llvm.org
Fri Mar 4 14:17:09 PST 2016
As a continuation of D17688 (add MSVC variants of strdup to leak checks),
I'm going to add a bunch of other Microsoft functions to the static
analyzer. I'm also going to add tempnam, a cstdlib function that returns a
pointer to memory that must be manually freed.
What other functions should I add?
Currently, I'm going to add:
A bunch of other functions that I'd like to add, but are non-trivial to
add, so I'll hold off on them for now:
- Aligned functions (I think that you're not supposed to mix them with
their non-aligned variants)
- Functions that should be freed with a function other than free:
- Functions that only return dynamically allocated memory in certain
- Functions that return dynamically allocated memory via an "_Out_"
- Functions which *may* allocate stack *or* heap:
- _malloca <https://msdn.microsoft.com/en-us/library/5471dc8s.aspx> (must
be freed with _freea
- Functions that return non-freeable memory, if passed NULL, but look
like users should free them. These two are very weird, and therefore it
might be very useful to check:
- tmpnam <http://en.cppreference.com/w/cpp/io/c/tmpnam>
- _wtmpnam <https://msdn.microsoft.com/en-us/library/hs3e7355.aspx>
*for the SAL obsessed (like me) it's actually
"Change the world or go home."
If left to my own devices, I will build more.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev