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
Free upon errors in config file(s) #133
Conversation
I'm going to work on a simpler/cleaner way of doing this. |
a52cd2e
to
5130e81
Compare
This now consists of the first 2 commits of the original PR. It leaves a FILE open and a 8192-char buffer, both from |
|
||
/* Find the start of the argument. */ | ||
conf_arg = conf_opt + optlen + 1; | ||
conf_arg += strspn(conf_arg, " \t"); | ||
bsdtar->conf_arg = bsdtar->conf_opt + optlen + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're setting bsdtar->conf_arg
to a string which was not allocated by malloc. What happens if we exit from this point?
5130e81
to
1915b90
Compare
Updated PR. |
} else { | ||
conf_arg_malloced = NULL; | ||
bsdtar->conf_arg = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we come here...
This moves the "allocated" version of conf_opt into the "global" bsdtar struct because if there's a config file error, we'll exit inside dooption(), leaving the previous local variable conf_opt un-freed.
This moves conf_arg_malloced into the "global" bsdtar struct because if there's a config file error, we'll exit inside dooption(), leaving the previous local variable conf_arg_malloced un-freed.
1915b90
to
5be74bc
Compare
Updated, and should be easier to read / track history now. |
Looks good to me. Should I merge now or did you want to rebase anything? |
Go ahead and merge it now. More granularity in the history isn't a bad thing. |
Makes valgrind happy if there's any problems in parsing the config file. I'm not 100% happy with this PR since it's a bit awkward due to interfacing with libarchive code (longer comments in a52cd2e), but it's worth bringing to your attention.