summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-07-25 20:55:02 +0200
committerMichael Vogt <mvo@debian.org>2013-07-25 20:55:02 +0200
commitde24f8ce508edd02690947d8dff7f0a4090a67fe (patch)
tree5db3189cfce8e6dc271c39023e49922aa5795b65 /cmdline
parent6612c86ef3d8f2b8bccc6212791996ab9e053082 (diff)
fix potential GetLock() fd leak
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-get.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 85ed80a95..73b396795 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -2290,9 +2290,10 @@ bool DoClean(CommandLine &CmdL)
FileFd Lock;
if (_config->FindB("Debug::NoLocking",false) == false)
{
- Lock.Fd(GetLock(archivedir + "lock"));
- if (_error->PendingError() == true)
+ int lock_fd = GetLock(archivedir + "lock");
+ if (lock_fd < 0)
return _error->Error(_("Unable to lock the download directory"));
+ Lock.Fd(lock_fd);
}
pkgAcquire Fetcher;
@@ -2326,9 +2327,10 @@ bool DoAutoClean(CommandLine &CmdL)
FileFd Lock;
if (_config->FindB("Debug::NoLocking",false) == false)
{
- Lock.Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock"));
- if (_error->PendingError() == true)
+ int lock_fd = GetLock(_config->FindDir("Dir::Cache::Archives") + "lock");
+ if (lock_fd < 0)
return _error->Error(_("Unable to lock the download directory"));
+ Lock.Fd(lock_fd);
}
CacheFile Cache;