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

fix the Memory leak: nbuf #297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/a12/a12.c
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,7 @@ void a12_enqueue_blob(struct a12_state* S, const char* const buf,
a12int_trace(A12_TRACE_SYSTEM, "kind=error:status=ENOMEM");
DYNAMIC_FREE(*next);
*next = NULL;
DYNAMIC_FREE(*nbuf);
Copy link

@CorruptedVor CorruptedVor Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more likely that the check was supposed to be if (!nbuf) on line 1553, and assuming correct usage of calling it with a non-NULL buf.

Copy link

@CorruptedVor CorruptedVor Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still incomplete, there is never a check for whether nbuf was allocated sucessfully.

In fact, when nbuf allocation fails, this dereferences nbuf anyway (*nbuf), which hopefully causes SIGSEGV

return;
}

Expand Down