diff options
author | Rene Scharfe <l.s.r@web.de> | 2017-08-30 19:49:33 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-09-07 01:49:26 +0200 |
commit | b36474ff6b4c7d0a4939b7551c576ef3de7e4719 (patch) | |
tree | d40425f225b35c69b22d377234571bf7961d8150 /builtin | |
parent | am: release strbufs after use in detect_patch_format() (diff) | |
download | git-b36474ff6b4c7d0a4939b7551c576ef3de7e4719.tar.xz git-b36474ff6b4c7d0a4939b7551c576ef3de7e4719.zip |
am: release strbuf on error return in hg_patch_to_mail()
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/am.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/builtin/am.c b/builtin/am.c index 3c50b03faa..3d38b3fe9f 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -881,6 +881,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths, static int hg_patch_to_mail(FILE *out, FILE *in, int keep_cr) { struct strbuf sb = STRBUF_INIT; + int rc = 0; while (!strbuf_getline_lf(&sb, in)) { const char *str; @@ -894,19 +895,27 @@ static int hg_patch_to_mail(FILE *out, FILE *in, int keep_cr) errno = 0; timestamp = parse_timestamp(str, &end, 10); - if (errno) - return error(_("invalid timestamp")); + if (errno) { + rc = error(_("invalid timestamp")); + goto exit; + } - if (!skip_prefix(end, " ", &str)) - return error(_("invalid Date line")); + if (!skip_prefix(end, " ", &str)) { + rc = error(_("invalid Date line")); + goto exit; + } errno = 0; tz = strtol(str, &end, 10); - if (errno) - return error(_("invalid timezone offset")); + if (errno) { + rc = error(_("invalid timezone offset")); + goto exit; + } - if (*end) - return error(_("invalid Date line")); + if (*end) { + rc = error(_("invalid Date line")); + goto exit; + } /* * mercurial's timezone is in seconds west of UTC, @@ -931,9 +940,9 @@ static int hg_patch_to_mail(FILE *out, FILE *in, int keep_cr) fwrite(sb.buf, 1, sb.len, out); strbuf_reset(&sb); } - +exit: strbuf_release(&sb); - return 0; + return rc; } /** |