SKY-D436 · Security in code
Repeated free of a local allocation
HighCWE-415
Skylos reports a second free of a known local malloc or calloc allocation in the same straight-line C++ block. The second call can refer to the original pointer or a tracked alias.
- Languages
- C++
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
Why it matters
Freeing the same allocation twice is undefined behavior and can corrupt allocator state.
What Skylos flags
#include <cstdlib> void release() { auto *ptr = static_cast<char *>(std::malloc(8)); auto *alias = ptr; std::free(ptr); std::free(alias);}What Skylos leaves alone
#include <cstdlib> void release() { auto *ptr = static_cast<char *>(std::malloc(8)); std::free(ptr);}Why Skylos leaves it alone
The allocation has one explicit release.
How Skylos decides
- Tracks a source-visible malloc or calloc allocation in a local pointer, including simple aliases within one straight-line block.
- Reports a second free of that allocation. A fresh allocation or a null pointer represents a different lifetime state.
How to fix it
Use one owner and release the allocation once. Prefer an RAII object or container that handles lifetime automatically.
When it can be wrong
- The analysis is bounded to straight-line local lifetimes. Verify behavior through ownership transfers, helper functions and control flow separately.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Mark the reviewed line with a rule-scoped Skylos ignore for SKY-D436. Record the evidence that justifies the exception.