summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-07-28 09:25:57 +0200
committerMichael Vogt <mvo@debian.org>2013-07-28 09:25:57 +0200
commit0c33605d981ceb78a4761e39043dc79ef9a571b2 (patch)
tree83fa22dda53f0abccd7b9cf7376af8553c559068 /apt-pkg/contrib/fileutl.cc
parent402c0d19a0c6668d7710b2b48561eb3059a04584 (diff)
parent163dc55bd6891008adcdf6d683a94e890a00f8c7 (diff)
Merge remote-tracking branch 'mvo/bugfix/coverity' into debian/sid
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 5debb4f92..f24df65fc 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -244,17 +244,20 @@ int GetLock(string File,bool Errors)
fl.l_len = 0;
if (fcntl(FD,F_SETLK,&fl) == -1)
{
+ // always close to not leak resources
+ int Tmp = errno;
+ close(FD);
+ errno = Tmp;
+
if (errno == ENOLCK)
{
_error->Warning(_("Not using locking for nfs mounted lock file %s"),File.c_str());
return dup(0); // Need something for the caller to close
- }
+ }
+
if (Errors == true)
_error->Errno("open",_("Could not get lock %s"),File.c_str());
- int Tmp = errno;
- close(FD);
- errno = Tmp;
return -1;
}
@@ -1218,11 +1221,9 @@ FileFd::~FileFd()
{
Close();
if (d != NULL)
- {
d->CloseDown(FileName);
- delete d;
- d = NULL;
- }
+ delete d;
+ d = NULL;
}
/*}}}*/
// FileFd::Read - Read a bit of the file /*{{{*/