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

struct: fix memory leak in buffer.pull() #260

Merged
merged 1 commit into from
Dec 31, 2024
Merged

Conversation

jow-
Copy link
Owner

@jow- jow- commented Dec 30, 2024

Do not increase the refcount when returning the pulled buffer contents as string since the returned value already is the sole reference. Without this change, pulled buffer contents will be leaked whenever the pull() function is used.

Also ensure that the buffer memory is completely zero initialized when it is allocated from scratch, the existing logic only cleared the trailing data area on reallocations but never the head on fresh allocations.

Do not increase the refcount when returning the pulled buffer contents
as string since the returned value already is the sole reference.
Without this change, pulled buffer contents will be leaked whenever
the `pull()` function is used.

Also ensure that the buffer memory is completely zero initialized when
it is allocated from scratch, the existing logic only cleared the trailing
data area on reallocations but never the head on fresh allocations.

Signed-off-by: Jo-Philipp Wich <[email protected]>
@jow- jow- merged commit 6443e75 into master Dec 31, 2024
3 checks passed
@jow- jow- deleted the struct-memory-fixes branch December 31, 2024 01:00
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

Successfully merging this pull request may close these issues.

1 participant