Skip to content

Commit 886e108

Browse files
Martin Ågrengitster
Martin Ågren
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4010f1d commit 886e108

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

builtin/checkout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
12911291
strbuf_release(&buf);
12921292
}
12931293

1294+
UNLEAK(opts);
12941295
if (opts.patch_mode || opts.pathspec.nr)
12951296
return checkout_paths(&opts, new.name);
12961297
else

builtin/diff-index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
5757
return -1;
5858
}
5959
result = run_diff_index(&rev, cached);
60+
UNLEAK(rev);
6061
return diff_result_code(&rev.diffopt, result);
6162
}

builtin/diff.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,5 +466,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
466466
result = diff_result_code(&rev.diffopt, result);
467467
if (1 < rev.diffopt.skip_stat_unmatch)
468468
refresh_index_quietly();
469+
UNLEAK(rev);
470+
UNLEAK(ent);
471+
UNLEAK(blob);
469472
return result;
470473
}

builtin/name-rev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,5 +494,6 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
494494
always, allow_undefined, data.name_only);
495495
}
496496

497+
UNLEAK(revs);
497498
return 0;
498499
}

builtin/tag.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,10 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
552552
if (force && !is_null_oid(&prev) && oidcmp(&prev, &object))
553553
printf(_("Updated tag '%s' (was %s)\n"), tag, find_unique_abbrev(prev.hash, DEFAULT_ABBREV));
554554

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);
559560
return 0;
560561
}

0 commit comments

Comments
 (0)