diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:58:47 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:58:47 +0000 |
commit | fe6489197b598e2ad255e204f1929ef62757399a (patch) | |
tree | 596142caa8424055a9a4b1d0d7933c90cde3b0b7 /cmdline/apt-cache.cc | |
parent | b454e81dedb0d05a30a148a9db2555e3cecae67c (diff) |
Fixed possible segv if there are no packages
Author: jgg
Date: 2001-12-07 05:57:43 GMT
Fixed possible segv if there are no packages
Diffstat (limited to 'cmdline/apt-cache.cc')
-rw-r--r-- | cmdline/apt-cache.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 3f7811c70..691899b3e 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: apt-cache.cc,v 1.52 2001/07/02 00:10:32 jgg Exp $ +// $Id: apt-cache.cc,v 1.53 2001/12/07 05:57:43 jgg Exp $ /* ###################################################################### apt-cache - Manages the cache files @@ -374,8 +374,9 @@ bool DumpAvail(CommandLine &Cmd) if (ReadPinFile(Plcy) == false) return false; - pkgCache::VerFile **VFList = new pkgCache::VerFile *[Cache.HeaderP->PackageCount]; - memset(VFList,0,sizeof(*VFList)*Cache.HeaderP->PackageCount); + unsigned long Count = Cache.HeaderP->PackageCount+1; + pkgCache::VerFile **VFList = new pkgCache::VerFile *[Count]; + memset(VFList,0,sizeof(*VFList)*Count); // Map versions that we want to write out onto the VerList array. for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++) @@ -428,7 +429,7 @@ bool DumpAvail(CommandLine &Cmd) VFList[P->ID] = VF; } - LocalitySort(VFList,Cache.HeaderP->PackageCount,sizeof(*VFList)); + LocalitySort(VFList,Count,sizeof(*VFList)); // Iterate over all the package files and write them out. char *Buffer = new char[Cache.HeaderP->MaxVerFileSize+10]; |