MEM-free-fptr
In this section:
Synopsis
A function pointer is deallocated.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
A function pointer is deallocated. Function pointers are not dynamically allocated, and should thus not be deallocated. Freeing a function pointer will result in undefined behavior.
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>
int id(int a) {
return a;
}
void example(void) {
int (*f)(int);
f = &id;
free((void *)f);
}
The following code example passes the check and will not give a warning about this issue:
#include <stdlib.h>
int id(int a) {
return a;
}
void example(void) {
int (*f)(int);
f = &id;
}