]> git.pond.sub.org Git - empserver/commitdiff
Plug FILE leak on show_first_tel() error paths
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 29 Oct 2011 13:35:43 +0000 (15:35 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 29 Dec 2011 10:47:05 +0000 (11:47 +0100)
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

index 687279678399644f09492695e584a6a626edd006..8592d2512ce0adb6e25a1a04fa77b7d824074e10 100644 (file)
@@ -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