From 886e1084d78cda218b4d1133e8154e8556f92222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C3=85gren?= Date: Sun, 1 Oct 2017 19:42:08 +0200 Subject: builtin/: add UNLEAKs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add some UNLEAKs where we are about to return from `cmd_*`. UNLEAK the variables in the same order as we've declared them. While addressing `msg` in builtin/tag.c, convert the existing `strbuf_release()` calls as well. Signed-off-by: Martin Ă…gren Signed-off-by: Junio C Hamano diff --git a/builtin/checkout.c b/builtin/checkout.c index 2d75ac6..fef94c0 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1291,6 +1291,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) strbuf_release(&buf); } + UNLEAK(opts); if (opts.patch_mode || opts.pathspec.nr) return checkout_paths(&opts, new.name); else diff --git a/builtin/diff-index.c b/builtin/diff-index.c index 185e6f9..09959f2 100644 --- a/builtin/diff-index.c +++ b/builtin/diff-index.c @@ -57,5 +57,6 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) return -1; } result = run_diff_index(&rev, cached); + UNLEAK(rev); return diff_result_code(&rev.diffopt, result); } diff --git a/builtin/diff.c b/builtin/diff.c index 7cde6ab..0da526c 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -466,5 +466,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix) result = diff_result_code(&rev.diffopt, result); if (1 < rev.diffopt.skip_stat_unmatch) refresh_index_quietly(); + UNLEAK(rev); + UNLEAK(ent); + UNLEAK(blob); return result; } diff --git a/builtin/name-rev.c b/builtin/name-rev.c index c41ea7c..9e584f5 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -494,5 +494,6 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) always, allow_undefined, data.name_only); } + UNLEAK(revs); return 0; } diff --git a/builtin/tag.c b/builtin/tag.c index 7a70d5a..14d1583 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -552,9 +552,10 @@ int cmd_tag(int argc, const char **argv, const char *prefix) if (force && !is_null_oid(&prev) && oidcmp(&prev, &object)) printf(_("Updated tag '%s' (was %s)\n"), tag, find_unique_abbrev(prev.hash, DEFAULT_ABBREV)); - strbuf_release(&err); - strbuf_release(&buf); - strbuf_release(&ref); - strbuf_release(&reflog_msg); + UNLEAK(buf); + UNLEAK(ref); + UNLEAK(reflog_msg); + UNLEAK(msg); + UNLEAK(err); return 0; } -- cgit v0.10.2-6-g49f6