MEM-free-no-alloc
In this section:
Synopsis
A pointer is freed without having been allocated.
Enabled by default
No
Severity/Certainty
Medium/Medium

Full description
A pointer is freed without having been allocated.
Coding standards
- CWE 590
Free of Memory not on the Heap
Code examples
The following code example fails the check and will give a warning:
#include <stdlib.h>
void example(void) {
int *p;
// Do stuff
free(p);
}
The following code example passes the check and will not give a warning about this issue:
#include <stdlib.h>
void example(void) {
int *p = malloc(sizeof(int));
// Do something
free(p);
}