diff options
| author | Lidong Yan <502024330056@smail.nju.edu.cn> | 2025-05-12 02:07:27 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-05-12 10:28:16 -0700 |
| commit | e5dd0a05ed392bc0c2dde84a1ee1d6eaeaac357f (patch) | |
| tree | d5378d10e2639c2c55caaa2587193103d626142c /builtin/am.c | |
| parent | Git 2.44.3 (diff) | |
| download | git-e5dd0a05ed392bc0c2dde84a1ee1d6eaeaac357f.tar.gz git-e5dd0a05ed392bc0c2dde84a1ee1d6eaeaac357f.zip | |
builtin/am: fix memory leak in `split_mail_stgit_series`
In builtin/am.c:split_mail_stgit_series, if `fopen` failed,
`series_dir_buf` allocated by `xstrdup` will leak. Add `free` in
`!fp` if branch will prevent the leak.
Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/am.c')
| -rw-r--r-- | builtin/am.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/am.c b/builtin/am.c index d1990d7edc..bb36b42aa1 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -848,8 +848,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 == '#') |
