builtin/: add UNLEAKs
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 <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Martin Ågren committed
Oct 1, 2017 at 19:42 UTC
886e1084d78cda218b4d1133e8154e8556f92222
5 files changed
+11
-4
builtin/checkout.c
+1
@@ -1291,6 +1291,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
1291
strbuf_release(&buf);
1292
}
1293
1294
+ UNLEAK(opts);
1295
if (opts.patch_mode || opts.pathspec.nr)
1296
return checkout_paths(&opts, new.name);
1297
else
builtin/diff-index.c
+1
@@ -57,5 +57,6 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
57
return -1;
58
}
59
result = run_diff_index(&rev, cached);
60
+ UNLEAK(rev);
61
return diff_result_code(&rev.diffopt, result);
62
}
builtin/diff.c
+3
@@ -466,5 +466,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
466
result = diff_result_code(&rev.diffopt, result);
467
if (1 < rev.diffopt.skip_stat_unmatch)
468
refresh_index_quietly();
469
+ UNLEAK(rev);
470
+ UNLEAK(ent);
471
+ UNLEAK(blob);
472
return result;
473
}
builtin/name-rev.c
+1
@@ -494,5 +494,6 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
494
always, allow_undefined, data.name_only);
495
}
496
497
+ UNLEAK(revs);
498
return 0;
499
}
builtin/tag.c
+5
-4
@@ -552,9 +552,10 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
552
if (force && !is_null_oid(&prev) && oidcmp(&prev, &object))
553
printf(_("Updated tag '%s' (was %s)\n"), tag, find_unique_abbrev(prev.hash, DEFAULT_ABBREV));
554
555
- strbuf_release(&err);
556
- strbuf_release(&buf);
557
- strbuf_release(&ref);
558
- strbuf_release(&reflog_msg);
555
+ UNLEAK(buf);
556
+ UNLEAK(ref);
557
+ UNLEAK(reflog_msg);
558
+ UNLEAK(msg);
559
+ UNLEAK(err);
560
return 0;
561
}