Ver código fonte

dpkg-divert: fix minor file descriptor leak found by cppcheck

Reported-by: Niels Thykier <niels@thykier.net>
Raphaël Hertzog 15 anos atrás
pai
commit
bdcee319a9
2 arquivos alterados com 4 adições e 1 exclusões
  1. 1 0
      debian/changelog
  2. 3 1
      src/divertcmd.c

+ 1 - 0
debian/changelog

@@ -102,6 +102,7 @@ dpkg (1.16.0) UNRELEASED; urgency=low
     Closes: #605719
     Closes: #605719
   * Fix dpkg-source's regression with empty patches (introduced while fixing
   * Fix dpkg-source's regression with empty patches (introduced while fixing
     #613023). Closes: #619541
     #613023). Closes: #619541
+  * Fix minor file descriptor leak found by cppcheck. Closes: #620380
 
 
   [ Jonathan Nieder ]
   [ Jonathan Nieder ]
   * Remove support for use of synchronous sync(2), due to its pernicious
   * Remove support for use of synchronous sync(2), due to its pernicious

+ 3 - 1
src/divertcmd.c

@@ -216,8 +216,10 @@ file_copy(const char *src, const char *dst)
 		return -1;
 		return -1;
 
 
 	dstfd = creat(dst, 0600);
 	dstfd = creat(dst, 0600);
-	if (dstfd < 0)
+	if (dstfd < 0) {
+		close(srcfd);
 		return -1;
 		return -1;
+	}
 
 
 	/* FIXME: leaves a dangling destination file on error. */
 	/* FIXME: leaves a dangling destination file on error. */