Просмотр исходного кода

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

Reported-by: Niels Thykier <niels@thykier.net>
Raphaël Hertzog лет назад: 15
Родитель
Сommit
bdcee319a9
2 измененных файлов с 4 добавлено и 1 удалено
  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
   * Fix dpkg-source's regression with empty patches (introduced while fixing
     #613023). Closes: #619541
+  * Fix minor file descriptor leak found by cppcheck. Closes: #620380
 
   [ Jonathan Nieder ]
   * 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;
 
 	dstfd = creat(dst, 0600);
-	if (dstfd < 0)
+	if (dstfd < 0) {
+		close(srcfd);
 		return -1;
+	}
 
 	/* FIXME: leaves a dangling destination file on error. */