summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-09-22 13:36:39 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-09-22 13:36:39 +0000
commit14cd494a9fa0d6801410bf121beb74ea631d59a6 (patch)
treeb25799799bb1f9d78ab167b91f21763ae3764aaa
parentceb00be9927199c067827a630ddc254149afcb57 (diff)
* make sure that the pkgRecords D'tor does not segfault
-rw-r--r--apt-pkg/pkgrecords.cc5
-rw-r--r--apt-pkg/pkgrecords.h1
-rw-r--r--cmdline/apt-get.cc2
3 files changed, 6 insertions, 2 deletions
diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc
index 9c2655d6a..1d71d3e2f 100644
--- a/apt-pkg/pkgrecords.cc
+++ b/apt-pkg/pkgrecords.cc
@@ -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;
}
diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h
index 08f004414..f31e83afe 100644
--- a/apt-pkg/pkgrecords.h
+++ b/apt-pkg/pkgrecords.h
@@ -33,6 +33,7 @@ class pkgRecords
pkgCache &Cache;
Parser **Files;
+ int PackageFileCount;
public:
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index ac931373d..a22d881b6 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -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);
}
}