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 Leaks Caused By realloc Failure #730

Closed
PengZheng opened this issue Feb 13, 2024 · 0 comments · Fixed by #733
Closed

Memory Leaks Caused By realloc Failure #730

PengZheng opened this issue Feb 13, 2024 · 0 comments · Fixed by #733
Assignees

Comments

@PengZheng
Copy link
Contributor

As mentioned in #727 (comment), the following code will leak the original memory block in case of realloc failure:

    seq->buf = realloc(seq->buf, (size_t)(cap * size));
    if (seq->buf == NULL) {
        seq->cap = 0;
        celix_err_pushf("Error allocating memory for seq buf");
        return MEM_ERROR;
    }

According to the manual page:

If realloc() fails, the original block is left untouched; it is not freed or moved.

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