]> git.saurik.com Git - apt.git/commitdiff
* make sure that the pkgRecords D'tor does not segfault
authorMichael Vogt <michael.vogt@ubuntu.com>
Thu, 22 Sep 2005 13:36:39 +0000 (13:36 +0000)
committerMichael Vogt <michael.vogt@ubuntu.com>
Thu, 22 Sep 2005 13:36:39 +0000 (13:36 +0000)
apt-pkg/pkgrecords.cc
apt-pkg/pkgrecords.h
cmdline/apt-get.cc

index 9c2655d6a774a3b452707f2f5958ec972fc3d7ed..1d71d3e2fb67af1085ea441ae64e2d75d8d3d39a 100644 (file)
@@ -42,6 +42,9 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0)
       if (Files[I->ID] == 0)
         return;
    }   
+   // We store that 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 +52,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 08f00441463e428da12e6268c9123a5116742f55..f31e83afefb9be378bc111bc951b7489835b9ab1 100644 (file)
@@ -33,6 +33,7 @@ class pkgRecords
    
    pkgCache &Cache;
    Parser **Files;
+   int PackageFileCount;
       
    public:
 
index ac931373ddd42b877698870ba6b57fca4c34f1c7..a22d881b6ab9f6992adec85e0a611994ca9b5d62 100644 (file)
@@ -2013,7 +2013,7 @@ bool DoSource(CommandLine &CmdL)
            if (system(S) != 0)
            {
               fprintf(stderr,_("Unpack command '%s' failed.\n"),S);
-              fprintf(stderr,_("Check if the 'dpkg-dev' package is installed.\n");
+              fprintf(stderr,_("Check if the 'dpkg-dev' package is installed.\n"));
               _exit(1);
            }       
         }