Files
codeql/cpp/ql/src/Critical/MemoryMayNotBeFreedGood.cpp
2018-08-02 17:53:23 +01:00

14 lines
261 B
C++

int* f() {
int *buff = NULL;
try {
buff = malloc(SIZE*sizeof(int));
do_stuff(buff);
return buff;
} catch (int do_stuff_exception) {
if (buff != NULL) {
free(buff);
}
return NULL; //returns NULL on error, having freed any allocated memory
}
}