CWE-562¶
Return of Stack Variable Address. [Bad-Coding-Practices, Improper-Adherence-To-Coding-Standards]
Required inputs: IR
Demonstrative Examples
Example 1
The following function returns a stack address.
Example Language:C
char* getName() {
char name[STR_MAX];
fillInName(name);
return name;
}Excerpts from CWE [https://cwe.mitre.org], Copyright (C) 2006-2026, the MITRE Corporation. See section 9.4. "3rd-Party Licenses" in the documentation for full details.Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
possibly_leaking_reference_to_local_variable |
Potentially leaking reference/pointer to local variable. |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
additional_pointer_returns¶
additional_pointer_returns : set[str] = set()
allow_longer_living_local¶
allow_longer_living_local : bool = False
consider_constructors_as_capturing¶
consider_constructors_as_capturing : bool = False
consider_pointer_returns¶
consider_pointer_returns : bool = False
std::string::data
consider_std_addressof¶
consider_std_addressof : bool = True
std::addressof as an address-taking operation.