summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2014-03-16 14:48:11 +0100
committerJulian Andres Klode <jak@debian.org>2015-08-27 13:45:57 +0200
commit2da8aae5550440742674758280f2d339ba612a31 (patch)
tree91933854b73c53a63da661e5c1e516514cbaa198
parent864fe99c3628585ba2081650e441ab15e4ee7bae (diff)
Always close compressed files in FileFd
We dup() the file descriptor when opening compressed files, so we always need to close the dup()ed one. Furthermore, not unsetting the d-pointer causes issues when running OpenDescriptor() multiple times on the same file descriptor.
-rw-r--r--apt-pkg/contrib/fileutl.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 1be782bac..d7c9424cf 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -2006,12 +2006,13 @@ bool FileFd::Close()
{
if ((Flags & Compressed) != Compressed && iFd > 0 && close(iFd) != 0)
Res &= _error->Errno("close",_("Problem closing the file %s"), FileName.c_str());
- if (d != NULL)
- {
- Res &= d->CloseDown(FileName);
- delete d;
- d = NULL;
- }
+ }
+
+ if (d != NULL)
+ {
+ Res &= d->CloseDown(FileName);
+ delete d;
+ d = NULL;
}
if ((Flags & Replace) == Replace) {