]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Don't leak the file descriptor pointed to by `in` if the first call to
authorNgie Cooper <yanegomi@gmail.com>
Sun, 11 Dec 2016 00:24:35 +0000 (16:24 -0800)
committerNgie Cooper <yanegomi@gmail.com>
Sun, 11 Dec 2016 00:24:35 +0000 (16:24 -0800)
fgets fails.

Reported by: Coverity
CID: 1331677

tar/test/main.c

index 6bc35578337247a69e72cd05219d12673c3cf615..9bb7964c465aa4cd49aa09d1ead7e388a4ead72d 100644 (file)
@@ -2324,7 +2324,7 @@ extract_reference_file(const char *name)
        for (;;) {
                if (fgets(buff, sizeof(buff), in) == NULL) {
                        /* TODO: This is a failure. */
-                       return;
+                       goto done;
                }
                if (memcmp(buff, "begin ", 6) == 0)
                        break;
@@ -2365,6 +2365,7 @@ extract_reference_file(const char *name)
                }
        }
        fclose(out);
+done:
        fclose(in);
 }