summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-05-09 19:16:39 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-05-09 19:16:39 +0200
commitafb093cd9bc9d0b2abb6a87d1b98785183a6452d (patch)
tree4420ed3fa0e77ed6136639bfc9f2c64df4632a46 /apt-pkg/contrib/fileutl.cc
parentee7af1bd58a717601fc30b5e7702d688749d2419 (diff)
* apt-pkg/contrib/fileutl.cc:
- check that the fd which are closed are valid
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index e9d1ba1ce..1cf225329 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1065,7 +1065,10 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
// We don't need the file open - instead let the compressor open it
// as he properly knows better how to efficiently read from 'his' file
if (FileName.empty() == false)
+ {
close(iFd);
+ iFd = -1;
+ }
}
// Create a data pipe
@@ -1133,7 +1136,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
close(Pipe[0]);
else
close(Pipe[1]);
- if (Comp == true || FileName.empty() == true)
+ if ((Comp == true || FileName.empty() == true) && d->compressed_fd != -1)
close(d->compressed_fd);
return true;
@@ -1355,8 +1358,9 @@ bool FileFd::Seek(unsigned long long To)
if (d->bz2 != NULL)
BZ2_bzclose(d->bz2);
#endif
- close(iFd);
- iFd = 0;
+ if (iFd != -1)
+ close(iFd);
+ iFd = -1;
if (TemporaryFileName.empty() == false)
iFd = open(TemporaryFileName.c_str(), O_RDONLY);
else if (FileName.empty() == false)