Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Programmers should be wary when freeing memory in a loop or conditional statement; if coded incorrectly, these constructs can lead to double-free vulnerabilities. It is also a common error to misuse the realloc() function in a manner that results in double-free vulnerabilities (see MEM04-C. Beware of zero-length allocations).

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

MEM30-C

High

Likely

Medium

P18

L1

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Related Guidelines

CERT C Secure Coding StandardMEM01-C. Store a new value in pointers immediately after free()
SEI CERT C++ Coding StandardMEM50-CPP. Do not access freed memory
ISO/IEC TR 24772:2013Dangling References to Stack Frames [DCM]
Dangling Reference to Heap [XYK]
ISO/IEC TS 17961

Accessing freed memory [accfree]
Freeing memory multiple times [dblfree]

MISRA C:2012Rule 18.6 (required)
MITRE CWE

CWE-415, Double Free
CWE-416, Use After Free

...