Bläddra i källkod

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.
Julian Andres Klode 12 år sedan
förälder
incheckning
2da8aae555
1 ändrade filer med 7 tillägg och 6 borttagningar
  1. 7 6
      apt-pkg/contrib/fileutl.cc

+ 7 - 6
apt-pkg/contrib/fileutl.cc

@@ -2006,12 +2006,13 @@ bool FileFd::Close()
    {
    {
       if ((Flags & Compressed) != Compressed && iFd > 0 && close(iFd) != 0)
       if ((Flags & Compressed) != Compressed && iFd > 0 && close(iFd) != 0)
 	 Res &= _error->Errno("close",_("Problem closing the file %s"), FileName.c_str());
 	 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) {
    if ((Flags & Replace) == Replace) {