]> git.saurik.com Git - apt.git/commitdiff
Always close compressed files in FileFd
authorJulian Andres Klode <jak@debian.org>
Sun, 16 Mar 2014 13:48:11 +0000 (14:48 +0100)
committerJulian Andres Klode <jak@debian.org>
Thu, 27 Aug 2015 11:45:57 +0000 (13:45 +0200)
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.

apt-pkg/contrib/fileutl.cc

index 1be782bac8c4629dd7fc81e1f276189db107d701..d7c9424cf63ce25e11cb5a3bed84281bb11f7709 100644 (file)
@@ -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) {