Package: cppcheck Version: 1.90-4 Severity: normal Hi!
There's a false positive about double free()s after a non-returning function pointer, even if that contains an explicit exit() or is marked with a __noreturn__ attribute. Attached a test case. Thanks, Guillem
#include <stdarg.h> #include <stdlib.h> #include <stdio.h> static void __attribute__((__noreturn__)) error(void) { exit(1); } void __attribute__((__noreturn__)) (*func_notret)(void); int main(int argc) { func_notret = error; void *ptr; ptr = malloc(1000); if (argc == 1) { free(ptr); func_notret(); } if (argc == 2) { free(ptr); func_notret(); } free(ptr); return 0; }