Skip to content

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

Open
@kostya253

Description

@kostya253

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions