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

Memory leak of allocations pointed to by variant_list[i].avg_times #55

Closed
ColinIanKing opened this issue Jun 4, 2020 · 1 comment
Closed

Comments

@ColinIanKing
Copy link
Contributor

In function run_tests in ipsec_perf.c any allocated avg_times buffers probably should be free'd before free'ing variant_list. This is a moot point because _exit() is being called afterwards anyhow, but it's nice to clean up correctly to clean up static analysis warnings :-)

2230        for (variant = 0, variant_ptr = variant_list;
2231             variant < total_variants;
2232             variant++, variant_ptr++) {
    CID 99591 (#4 of 4): Resource leak (RESOURCE_LEAK) 

    41. alloc_fn: Storage is returned from allocation function malloc.
    42. var_assign: Assigning: variant_ptr->avg_times = storage returned from malloc(at_size).
    43. var_assign: Assigning: variant_list->avg_times = variant_ptr->avg_times.

2233                variant_ptr->avg_times = (uint64_t *) malloc(at_size);

    44. Condition !variant_ptr->avg_times, taking false branch.
    47. Condition !variant_ptr->avg_times, taking false branch.

2234                if (!variant_ptr->avg_times) {
2235                        fprintf(stderr, "Cannot allocate memory\n");
2236                        goto exit_failure;
2237                }

and the free'ing:

2296exit_failure:
2297        if (variant_list != NULL)
    CID 99591 (#2 of 4): Resource leak (RESOURCE_LEAK) [select issue]
2298                free(variant_list);
2299        free_mem(&buf, &keys);
2300        free_mb_mgr(p_mgr);
2301        exit(EXIT_FAILURE);
@pablodelara
Copy link
Contributor

Thanks for reporting, @ColinIanKing. Will fix it shortly.

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

3 participants