[metadata]
id = "MEM34-C"
type = "rule"
category = "MEM"
number = 34
title = "Only free memory allocated dynamically"
description = """
The C Standard, Annex J (184) [ISO/IEC 9899:2024], states that the behavior of a
program isundefinedwhen See alsoundefined behavior 184. Freeing memory that is
not allocated dynamically can result in heap corruption and other serious
errors. Do not callfree()on a pointer other than one returned by a standard
memory allocation function, such asmalloc(),calloc(),realloc(),
oraligned_alloc().
"""
severity = "High"
likelihood = "Likely"
priority = "P9"
level = "L2"
cert_version = "2016 Edition (Wiki)"
last_modified = "Aug 06, 2025"
[rules.cert_c.MEM34-C]
enabled = true
[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/MEM34-C.+Only+free+memory+allocated+dynamically"
cwe = ["CWE-590"]