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>
This commit is contained in:
parent
542627a4f7
commit
b36474ff6b
29
builtin/am.c
29
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user