Function-like macros should not be invoked without all of their arguments | Bug | cwe, misra, preprocessor | This is a constraint error, but preprocessors have been known to ignore this problem. Each argument in a function-like macro must consist of at least one preprocessing token otherwise the behaviour is undefined. See |
Stack allocated memory should not be freed | Bug | unpredictable | Stack allocated memory, like memory allocated with the functions alloca, _alloca, _malloca, __builtin_alloca, is automatically released at the end of the function, and should not be released with free. Explicitly free-ing such memory results in undefined behavior. Noncompliant Code Example void fun() { char *name = (char *) alloca(size); // ... free(name); // Noncompliant, memory allocated on the stack char *name2 = "name"; // ... free(name2); // Noncompliant, memory allocated on the stack }
void fun() { char *name = (char *) alloca(size); // ... char *name2 = "name"; // ... } |