diff --git a/builtin/am.c b/builtin/am.c index 4afb519830..e32a3b4c97 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -850,8 +850,10 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths, series_dir = dirname(series_dir_buf); fp = fopen(*paths, "r"); - if (!fp) + if (!fp) { + free(series_dir_buf); return error_errno(_("could not open '%s' for reading"), *paths); + } while (!strbuf_getline_lf(&sb, fp)) { if (*sb.buf == '#')