Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A false report in Infer 1.2.0 #1851

Open
Zustin opened this issue Jul 9, 2024 · 0 comments
Open

A false report in Infer 1.2.0 #1851

Zustin opened this issue Jul 9, 2024 · 0 comments

Comments

@Zustin
Copy link

Zustin commented Jul 9, 2024

Please make sure your issue is not addressed in the FAQ.
I used infer to detect the following program. It is obvious that the program has a double free issue, but Infer reports a false warnign "use after free". See the log below.

double_free.c

#include <stdlib.h>

void double_free_example() {
    int *ptr = (int *)malloc(sizeof(int));
    if (ptr == NULL) {
        return;
    }
    free(ptr);
    free(ptr); // This is a double-free error
}

int main() {
    double_free_example();
    return 0;
}

Log

Capturing in make/cc mode...
Found 1 source file to analyze in /Users/rainyd4y/code/infer-out
3/3 [################################################################################] 100% 293ms

double_free.c:9: error: Use After Free
  accessing `ptr` that was invalidated by call to `free()` on line 8.
   7.     }
   8.     free(ptr);
   9.     free(ptr); // This is a double-free error
          ^
  10. }
  11.
Found 1 issue
      Issue Type(ISSUED_TYPE_ID): #
  Use After Free(USE_AFTER_FREE): 1

I used Infer 1.2.0 and MacOS version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant