summaryrefslogtreecommitdiff
path: root/cmdline/apt-get.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-07-05 08:21:28 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-31 13:49:37 +0200
commitd30f800560010cb123fdd74b46c727df0e54eaed (patch)
treec74a1b75c3b5dfcbcc57a3f32955afdce25a1a49 /cmdline/apt-get.cc
parentde2c7e41ab4fe0e1e899e1d87c991e32cd343365 (diff)
indextargets: Check that cache could be built before using it
This caused a crash because the cache was a nullptr. Closes: #829651 (cherry picked from commit 8823972649b0d3049c9c0d34b5f1d31160234fb4)
Diffstat (limited to 'cmdline/apt-get.cc')
-rw-r--r--cmdline/apt-get.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 4ac15274c..58c06092d 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -248,8 +248,9 @@ static bool DoIndexTargets(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgSourceList *SrcList = CacheFile.GetSourceList();
+ pkgCache *Cache = CacheFile.GetPkgCache();
- if (SrcList == NULL)
+ if (SrcList == nullptr || Cache == nullptr)
return false;
std::string const Format = _config->Find("APT::Get::IndexTargets::Format");
@@ -262,8 +263,7 @@ static bool DoIndexTargets(CommandLine &CmdL)
if (ReleaseInfo)
{
AddOptions.insert(std::make_pair("TRUSTED", ((*S)->IsTrusted() ? "yes" : "no")));
- pkgCache &Cache = *CacheFile.GetPkgCache();
- pkgCache::RlsFileIterator const RlsFile = (*S)->FindInCache(Cache, false);
+ pkgCache::RlsFileIterator const RlsFile = (*S)->FindInCache(*Cache, false);
if (RlsFile.end())
continue;
#define APT_RELEASE(X,Y) if (RlsFile.Y() != NULL) AddOptions.insert(std::make_pair(X, RlsFile.Y()))