]> git.saurik.com Git - apt.git/commitdiff
* Small bugfix to pkgRecords to prevent a segfault if t...
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 17:03:33 +0000 (17:03 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 17:03:33 +0000 (17:03 +0000)
Author: mdz
Date: 2003-09-02 04:46:18 GMT
* Small bugfix to pkgRecords to prevent a segfault if the pkgCache is
destroyed before it (from Conectiva's apt-rpm)

apt-pkg/pkgrecords.cc
debian/changelog

index 69aac662200440fd0cf2b70d89e9c57104aaba89..a7dec76a7a82ba16d6670064f30c2b41f7d24fda 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgrecords.cc,v 1.6 2001/02/20 07:03:17 jgg Exp $
+// $Id: pkgrecords.cc,v 1.7 2003/09/02 04:46:18 mdz Exp $
 /* ######################################################################
    
    Package Records - Allows access to complete package description records
@@ -42,6 +42,10 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0)
       if (Files[I->ID] == 0)
         return;
    }   
+   
+   // We store this to make sure that the destructor won't segfault,
+   // even if the Cache object was destructed before this instance.
+   PackageFileCount = Cache.HeaderP->PackageFileCount;
 }
                                                                        /*}}}*/
 // Records::~pkgRecords - Destructor                                   /*{{{*/
@@ -49,7 +53,7 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0)
 /* */
 pkgRecords::~pkgRecords()
 {
-   for (unsigned I = 0; I != Cache.HeaderP->PackageFileCount; I++)
+   for (unsigned I = 0; I != PackageFileCount; I++)
       delete Files[I];
    delete [] Files;
 }
index b3998e1963129b64026c5c6c543b939e3d202c68..1c37b8142e8ddaa6484576a6ce5db597865984ed 100644 (file)
@@ -4,6 +4,8 @@ apt (0.5.11) unstable; urgency=low
     (Closes: #208302)
   * In apt.conf(5), give the fully qualified name of Dir::Bin::Methods,
     rather than just "methods"
+  * Small bugfix to pkgRecords to prevent a segfault if the pkgCache is
+    destroyed before it (from Conectiva's apt-rpm)
 
  --