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 common realloc mistake in custom_output_search_replace.c #931

Merged
merged 1 commit into from
Sep 27, 2016

Conversation

bryonglodencissp
Copy link
Contributor

Passing one pointer into realloc() and assigning the result directly into that same pointer variable can cause a memory leak if the reallocation fails, because the original allocation will still exist. The correct way to do this is to use a temporary pointer variable.

Found by https://github.com/bryongloden/cppcheck

[src/shared/custom_output_search_replace.c:39]: (error) Common realloc mistake: 'tmp' nulled but not freed upon failure
[src/shared/custom_output_search_replace.c:52]: (error) Common realloc mistake: 'tmp' nulled but not freed upon failure
[src/shared/custom_output_search_replace.c:67]: (error) Common realloc mistake: 'tmp' nulled but not freed upon failure
@ddpbsd ddpbsd merged commit 80d1262 into ossec:master Sep 27, 2016
@ddpbsd
Copy link
Member

ddpbsd commented Sep 27, 2016

Thanks for the patch!

@vikman90 vikman90 mentioned this pull request Dec 21, 2016
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.

None yet

2 participants