Skip to main content

SKY-D436 · Security in code

Repeated free of a local allocation

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Freeing the same allocation twice is undefined behavior and can corrupt allocator state.

What Skylos flags

release.cpp · C++Reported on line 7
#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

release.cpp · C++
#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

  1. Tracks a source-visible malloc or calloc allocation in a local pointer, including simple aliases within one straight-line block.
  2. 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.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.