Skip to content

fix: only update the buffer if realloc succeeded#76

Open
thien-codev wants to merge 1 commit intoswiftlang:gfmfrom
thien-codev:fix/avoid-memory-leak-when-using-realloc
Open

fix: only update the buffer if realloc succeeded#76
thien-codev wants to merge 1 commit intoswiftlang:gfmfrom
thien-codev:fix/avoid-memory-leak-when-using-realloc

Conversation

@thien-codev
Copy link
Copy Markdown

  • When realloc fails, it returns NULL, and the original memory block remains allocated. In the current implementation, if realloc fails, the original memory block is overwritten (i.e., the buf->ptr gets NULL), causing the reference to the original memory to be lost, leading to a memory leak.

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