From: Stefan Beller <hidden> Date: 2016-06-15 23:09:09
Thanks for the reviews!
Thanks Jeff, Eric, Junio!
This replaces sb/misc-cleanups.
* Revert the builtin/notes fix to the first version as git_config_get_value
is dangerous, and the memory allocation and free is just a small overhead here
* the bundle code integrates all of the suggestions (i.e. rollback_lock_file
conditioned on (!bundle_to_stdout).
I hope I got everything by now. I will head out for today and tomorrow I'll
be traveling to NY, where there is the Git Merge conference on Mon, Tues and some
vacation afterwards. I'll be online in a very limited fashion. (I plan on taking
my phone only, no laptop), so in case I missed a thing this series will halt
for a while or someone else picks it up.
Thanks,
Stefan
diff to remotes/origin/sb/misc-cleanups (which doesn't contain the bundle fix):
From: Stefan Beller <hidden> Date: 2016-06-15 23:09:09
`value` is just a temporary scratchpad, so we need to make sure it doesn't
leak. It is xstrdup'd in `git_config_get_string_const` and
`parse_notes_merge_strategy` just compares the string against predefined
values, so no need to keep it around longer.
Signed-off-by: Stefan Beller <redacted>
---
builtin/notes.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
From: Stefan Beller <hidden> Date: 2016-06-15 23:09:09
In successful operation `write_pack_data` will close the `bundle_fd`,
but when we exit early, we need to take care of the file descriptor
as well as the lock file ourselves. The lock file may be deleted at the
end of running the program, but we are in library code, so we should
not rely on that.
Helped-by: Jeff King [off-list ref]
Signed-off-by: Stefan Beller <redacted>
---
bundle.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
From: Stefan Beller <hidden> Date: 2016-06-15 23:09:09
`split` is of type `struct strbuf **`, and currently we are leaking split
itself as well as each element in split[i]. We have a dedicated free
function for `struct strbuf **`, which takes care of freeing all
related memory.
Helped-by: Eric Sunshine [off-list ref]
Signed-off-by: Stefan Beller <redacted>
---
wt-status.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
From: Eric Sunshine <hidden> Date: 2016-06-15 23:09:09
On Thu, Mar 31, 2016 at 8:35 PM, Stefan Beller [off-list ref] wrote:
quoted hunk
`value` is just a temporary scratchpad, so we need to make sure it doesn't
leak. It is xstrdup'd in `git_config_get_string_const` and
`parse_notes_merge_strategy` just compares the string against predefined
values, so no need to keep it around longer.
Signed-off-by: Stefan Beller <redacted>
---
@@ -741,13 +741,14 @@ static int merge_commit(struct notes_merge_options *o)staticintgit_config_get_notes_strategy(constchar*key,enumnotes_merge_strategy*strategy){-constchar*value;+char*value;-if(git_config_get_string_const(key,&value))+if(git_config_get_string(key,&value))return1;
Meh. Rather than reverting the git_config_get_value(), it would have
been just as easy and safer (less chance of a future change
re-introducing a leak) if you had just inserted the necessary check
here:
if (!value)
return config_error_nonbool(key);
But, perhaps it's not worth the patch churn at this point...