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

Prevent double-free strbuf when nsyms is 0 #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wgh1688
Copy link

@wgh1688 wgh1688 commented Oct 11, 2024

When nsyms is 0, 'last' will be equal to 'first', and strbuf will not get a new memory buf. But strbuf is not NULL now, because in the last loop, strbuf may get a memory buf allocated by 'calloc', which is only freed in the loop end but not set to NULL. If we don't set strbuf to NULL in such a case, strbuf will be double freed in the following FREEBUF(strbuf) sentence.

When nsyms is 0, 'last' will be equal to 'first', and strbuf will not
get a new memory buf. But strbuf is not NULL now, because in the last
loop, strbuf may get a memory buf allocated by 'calloc', which is only
freed in the loop end but not set to NULL. If we don't set strbuf to
NULL in such a case, strbuf will be double freed in the following
FREEBUF(strbuf) sentence.

Signed-off-by: Wang Guanghui <[email protected]>
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