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
@ -1018,13 +1018,14 @@ static int store_stash(int argc, const char **argv, const char *prefix)
|
||||
int quiet = 0;
|
||||
const char *stash_msg = NULL;
|
||||
struct object_id obj;
|
||||
struct object_context dummy;
|
||||
struct object_context dummy = {0};
|
||||
struct option options[] = {
|
||||
OPT__QUIET(&quiet, N_("be quiet")),
|
||||
OPT_STRING('m', "message", &stash_msg, "message",
|
||||
N_("stash message")),
|
||||
OPT_END()
|
||||
};
|
||||
int ret;
|
||||
|
||||
argc = parse_options(argc, argv, prefix, options,
|
||||
git_stash_store_usage,
|
||||
@ -1043,10 +1044,15 @@ static int store_stash(int argc, const char **argv, const char *prefix)
|
||||
if (!quiet)
|
||||
fprintf_ln(stderr, _("Cannot update %s with %s"),
|
||||
ref_stash, argv[0]);
|
||||
return -1;
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
return do_store_stash(&obj, stash_msg, quiet);
|
||||
ret = do_store_stash(&obj, stash_msg, quiet);
|
||||
|
||||
out:
|
||||
object_context_release(&dummy);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void add_pathspecs(struct strvec *args,
|
||||
|
Reference in New Issue
Block a user