From 0b66d8e281d9c0d646c66cffe976ba19cd53f55f Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 29 Oct 2011 15:35:43 +0200 Subject: [PATCH] Plug FILE leak on show_first_tel() error paths Leak introduced in commit 4238323d, v4.3.20. Unlikely to bite in practice, as only corrupt mailbox files can cause these errors. --- src/lib/commands/rea.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/commands/rea.c b/src/lib/commands/rea.c index 68727967..8592d251 100644 --- a/src/lib/commands/rea.c +++ b/src/lib/commands/rea.c @@ -209,6 +209,7 @@ int show_first_tel(char *fname) { FILE *fp; + int ret; struct telstr tgm; if ((fp = fopen(fname, "rb")) == NULL) { @@ -219,12 +220,15 @@ show_first_tel(char *fname) return -1; } } - if (tel_read_header(fp, fname, &tgm) < 0) - return -1; - if (tel_read_body(fp, fname, &tgm, print_sink, NULL) < 0) - return -1; + + ret = tel_read_header(fp, fname, &tgm); + if (ret < 0) + goto out; + ret = tel_read_body(fp, fname, &tgm, print_sink, NULL); + +out: fclose(fp); - return 0; + return ret; } static int