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

c/lang/security/double-free.yaml false positive #2995

Open
1 task
kostya253 opened this issue Jul 4, 2023 · 0 comments
Open
1 task

c/lang/security/double-free.yaml false positive #2995

kostya253 opened this issue Jul 4, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@kostya253
Copy link

kostya253 commented Jul 4, 2023

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
@kostya253 kostya253 added the bug Something isn't working label Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant