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 memory leaks in write_c and eval_shell #165

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

Conversation

ashamedbit
Copy link

Hi,
I am a new contributor looking forward to contribute to the shc project :).
I came across the following open issue here #155
It is a leaksanitizer report which detects a leak that happens on passing a simple bash script.
I was able to reproduce the bug on running a custom shell script and was able to generate a patch for it. The leak happens within function write_c. Basically all the allocated variables in this function including msg1, msg2, chk1, chk2, tst1, tst2 and name need to be freed after allocation. I have a model patch and I was wondering if I can merge the same.

I was able to verify that after the patch, the leak no longer occurs through leaksanitizer (and there is no double free for that matter)

In addition I have also patched a leak that I encountered when running on an invalid bash script. This new leak happens in eval_shell function when an invalid first line on script is encountered. Here ptr is allocated but not freed before the abrupt exit.

Let me know if this is a good patch! If not let me know what changes need be done. I am eager to become a regular contributor to this repository :)

@suntong
Copy link
Contributor

suntong commented Aug 10, 2024

LGTM, @neurobin?

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.

2 participants