diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-06-04 03:21:04 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-04 03:21:04 +0200 |
commit | 34bbe2edd47cf22a7af361f8ec9d41c5ec95aaac (patch) | |
tree | 2518c80fab78106a36801c02b6b2a53628fa7c82 /builtin/am.c | |
parent | Merge branch 'js/eol-on-ourselves' into maint (diff) | |
parent | checkout: fix memory leak (diff) | |
download | git-34bbe2edd47cf22a7af361f8ec9d41c5ec95aaac.tar.xz git-34bbe2edd47cf22a7af361f8ec9d41c5ec95aaac.zip |
Merge branch 'js/plug-leaks' into maint
Fix memory leaks pointed out by Coverity (and people).
* js/plug-leaks: (26 commits)
checkout: fix memory leak
submodule_uses_worktrees(): plug memory leak
show_worktree(): plug memory leak
name-rev: avoid leaking memory in the `deref` case
remote: plug memory leak in match_explicit()
add_reflog_for_walk: avoid memory leak
shallow: avoid memory leak
line-log: avoid memory leak
receive-pack: plug memory leak in update()
fast-export: avoid leaking memory in handle_tag()
mktree: plug memory leaks reported by Coverity
pack-redundant: plug memory leak
setup_discovered_git_dir(): plug memory leak
setup_bare_git_dir(): help static analysis
split_commit_in_progress(): simplify & fix memory leak
checkout: fix memory leak
cat-file: fix memory leak
mailinfo & mailsplit: check for EOF while parsing
status: close file descriptor after reading git-rebase-todo
difftool: address a couple of resource/memory leaks
...
Diffstat (limited to 'builtin/am.c')
-rw-r--r-- | builtin/am.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/builtin/am.c b/builtin/am.c index 7d39156ff3..4b89289d1e 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1351,19 +1351,16 @@ static int get_mail_commit_oid(struct object_id *commit_id, const char *mail) struct strbuf sb = STRBUF_INIT; FILE *fp = xfopen(mail, "r"); const char *x; + int ret = 0; - if (strbuf_getline_lf(&sb, fp)) - return -1; - - if (!skip_prefix(sb.buf, "From ", &x)) - return -1; - - if (get_oid_hex(x, commit_id) < 0) - return -1; + if (strbuf_getline_lf(&sb, fp) || + !skip_prefix(sb.buf, "From ", &x) || + get_oid_hex(x, commit_id) < 0) + ret = -1; strbuf_release(&sb); fclose(fp); - return 0; + return ret; } /** |