Bug#607803: apt: popen/fclose mismatch in dpkgmp.cpp (log file descriptor)
Package: apt
Version: 0.8.10
Severity: minor
Tags: patch
Looking at
<URL:http://qa.debian.org/daca/cppcheck/sid/apt_0.8.10.html>, I saw
this error that should be easy to fix:
# ./apt-pkg/deb/dpkgpm.cc:1418 [error] - Mismatching allocation and deallocation: log
# ./apt-pkg/deb/dpkgpm.cc:1434 [error] - Mismatching allocation and deallocation: log
Looking at the source, the bug is obvious (popen() and fclose()), and
this fix solve the issue:
--- apt-pkg/deb/dpkgpm.cc.orig 2010-12-22 13:29:15.000000000 +0100
+++ apt-pkg/deb/dpkgpm.cc 2010-12-22 13:30:05.000000000 +0100
@@ -1415,7 +1415,7 @@
{
while( fgets(buf, sizeof(buf), log) != NULL)
fprintf(report, " %s", buf);
- fclose(log);
+ pclose(log);
}
}
@@ -1431,7 +1431,7 @@
{
while( fgets(buf, sizeof(buf), log) != NULL)
fprintf(report, " %s", buf);
- fclose(log);
+ pclose(log);
}
}
Happy hacking,
--
Petter Reinholdtsen
Reply to: