]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/cachefile.cc
fix typo in SrvRecords documentation
[apt.git] / apt-pkg / cachefile.cc
index aaa2436c5d787fcf4bcad623b1f93afc37efb963..92a3b201bb8524f9f3e4f0252cd8ef70f7928387 100644 (file)
@@ -80,6 +80,8 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
       if (file.IsOpen() == false || file.Failed())
         return false;
       Map = new MMap(file, MMap::Public|MMap::ReadOnly);
+      if (unlikely(Map->validData() == false))
+        return false;
       Cache = new pkgCache(Map);
       return _error->PendingError() == false;
    }
@@ -94,7 +96,8 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
    BuildSourceList(Progress);
 
    // Read the caches
-   bool Res = pkgCacheGenerator::MakeStatusCache(*SrcList,Progress,&Map, true);
+   Cache = nullptr;
+   bool Res = pkgCacheGenerator::MakeStatusCache(*SrcList,Progress,&Map, &Cache, true);
    if (Progress != NULL)
       Progress->Done();
    if (Res == false)
@@ -104,7 +107,8 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
    if (_error->PendingError() == true)
       _error->Warning(_("You may want to run apt-get update to correct these problems"));
 
-   Cache = new pkgCache(Map);
+   if (Cache == nullptr)
+      Cache = new pkgCache(Map);
    if (_error->PendingError() == true)
       return false;
    return true;