object-name: free leaking object contexts
While it is documented in `struct object_context::path` that this variable needs to be released by the caller, this fact is rather easy to miss given that we do not ever provide a function to release the object context. And of course, while some callers dutifully release the path, many others don't. Introduce a new `object_context_release()` function that releases the path. Convert callsites that used to free the path to use that new function and add missing calls to callsites that were leaking memory. Refactor those callsites as required to have a single return path, only. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
61f8bb1ec1
commit
f87c55c264
@ -367,7 +367,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
|
||||
OPT_END()
|
||||
};
|
||||
struct ls_tree_cmdmode_to_fmt *m2f = ls_tree_cmdmode_format;
|
||||
struct object_context obj_context;
|
||||
struct object_context obj_context = {0};
|
||||
int ret;
|
||||
|
||||
git_config(git_default_config, NULL);
|
||||
@ -441,5 +441,6 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
|
||||
|
||||
ret = !!read_tree(the_repository, tree, &options.pathspec, fn, &options);
|
||||
clear_pathspec(&options.pathspec);
|
||||
object_context_release(&obj_context);
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user