Miscellaneous-NoUncheckedMalloc¶
The result of calls to the library functions “malloc”, “calloc”, and “realloc” must be checked
Required inputs: IR
NULL result immediately after calling a memory allocation function
to avoid undefined behavior when running out of memory.
Example
S* ps = (S*)malloc(sizeof(S));
if (ps == NULL)
{
return ERR_OUT_OF_MEMORY;
}
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
unchecked_malloc |
Result of call to malloc, calloc, or realloc is not checked. |
None |
False |
unchecked_new |
Result of call to non-throwing operator new is not checked. |
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
check_nothrow_new¶
check_nothrow_new : bool = False
null_check_macro¶
null_check_macro : bauhaus.analysis.config.MacroName = ''
NULL.