Open
Description
Describe the bug
The rule produces false positives, when goto or return are using between the search patterns
To Reproduce
This following code should be ok, but it fails the rule, free is called once for non NULL, and if the var is NULL (If ptr is null, the free() function does nothing.) its called twice.
int okay_code1() {
char *var = malloc(sizeof(char) * 10);
if (var != NULL)
goto error;
// ok: double-free
free(var);
error:
free(var);
return 0;
}
Expected behavior
The above code should not be detected as double free.
Priority
How important is this to you?
- P2: annoying but not blocking me