]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-cache.cc
fix memory leaks reported by -fsanitize
[apt.git] / cmdline / apt-cache.cc
index 690b03bcc7faf1f8aa68d9b1388604177c8425d1..9c884433c8be4c19e7c96337d0c55eb21256becd 100644 (file)
@@ -413,17 +413,21 @@ static bool Stats(CommandLine &)
            stritems.insert(Prv->ProvideVersion);
       }
    }
-   for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); ++F)
+   for (pkgCache::RlsFileIterator F = Cache->RlsFileBegin(); F != Cache->RlsFileEnd(); ++F)
    {
       stritems.insert(F->FileName);
       stritems.insert(F->Archive);
       stritems.insert(F->Codename);
-      stritems.insert(F->Component);
       stritems.insert(F->Version);
       stritems.insert(F->Origin);
       stritems.insert(F->Label);
-      stritems.insert(F->Architecture);
       stritems.insert(F->Site);
+   }
+   for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); ++F)
+   {
+      stritems.insert(F->FileName);
+      stritems.insert(F->Architecture);
+      stritems.insert(F->Component);
       stritems.insert(F->IndexType);
    }
    unsigned long Size = 0;
@@ -446,6 +450,7 @@ static bool Stats(CommandLine &)
       APT_CACHESIZE(VersionCount, VersionSz) +
       APT_CACHESIZE(DescriptionCount, DescriptionSz) +
       APT_CACHESIZE(DependsCount, DependencySz) +
+      APT_CACHESIZE(ReleaseFileCount, ReleaseFileSz) +
       APT_CACHESIZE(PackageFileCount, PackageFileSz) +
       APT_CACHESIZE(VerFileCount, VerFileSz) +
       APT_CACHESIZE(DescFileCount, DescFileSz) +
@@ -1479,6 +1484,7 @@ static bool Search(CommandLine &CmdL)
    delete [] PatternMatch;
    for (unsigned I = 0; I != NumPatterns; I++)
       regfree(&Patterns[I]);
+   delete [] Patterns;
    if (ferror(stdout))
        return _error->Error("Write to stdout failed");
    return true;
@@ -1633,6 +1639,8 @@ static bool Policy(CommandLine &CmdL)
       cout << _("Package files:") << endl;   
       for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; ++F)
       {
+        if (F.Flagged(pkgCache::Flag::NoPackages))
+           continue;
         // Locate the associated index files so we can derive a description
         pkgIndexFile *Indx;
         if (SrcList->FindIndex(F,Indx) == false &&
@@ -1721,7 +1729,7 @@ static bool Policy(CommandLine &CmdL)
            cout << " *** " << V.VerStr();
         else
            cout << "     " << V.VerStr();
-        cout << " " << Plcy->GetPriority(Pkg) << endl;
+        cout << " " << Plcy->GetPriority(V) << endl;
         for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; ++VF)
         {
            // Locate the associated index files so we can derive a description