From: Ngie Cooper Date: Sun, 11 Dec 2016 00:24:35 +0000 (-0800) Subject: Don't leak the file descriptor pointed to by `in` if the first call to X-Git-Tag: v3.3.0~90^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1b1881dfed9e8f4b2487aa74f6d151b1047539f;p=thirdparty%2Flibarchive.git Don't leak the file descriptor pointed to by `in` if the first call to fgets fails. Reported by: Coverity CID: 1331677 --- diff --git a/tar/test/main.c b/tar/test/main.c index 6bc355783..9bb7964c4 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -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); }