MEM-free-no-use
In this section:
Synopsis
Memory is allocated and then freed without being used.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
Memory is allocated and then freed without being used. This is probably unintentional and might indicate a copy-paste error.
Coding standards
This check does not correspond to any coding standard rules.
Code examples
The following code example fails the check and will give a warning:
#include <stdlib.h>
void example(void) {
int *p = malloc(sizeof(int));
free(p);
}
The following code example passes the check and will not give a warning about this issue:
#include <stdlib.h>
int * foo() {
return (int *) 0xF0000000;
}
void example(void) {
int *p = malloc(sizeof(int));
*p = 1;
free(p);
p = foo();
free(p);
}