Просмотр исходного кода

Fixed a possible segfault
Author: jgg
Date: 2001-12-26 06:47:37 GMT
Fixed a possible segfault

Arch Librarian лет назад: 22
Родитель
Сommit
2a3f3893b2
2 измененных файлов с 7 добавлено и 5 удалено
  1. 5 3
      apt-pkg/algorithms.cc
  2. 2 2
      cmdline/apt-cache.cc

+ 5 - 3
apt-pkg/algorithms.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: algorithms.cc,v 1.36 2001/05/27 03:46:10 jgg Exp $
+// $Id: algorithms.cc,v 1.37 2001/12/26 06:47:37 jgg Exp $
 /* ######################################################################
 
    Algorithms - A set of misc algorithms
@@ -225,7 +225,8 @@ bool pkgApplyStatus(pkgDepCache &Cache)
 	 else
 	 {
 	    // Is this right? Will dpkg choke on an upgrade?
-	    if (Cache[I].CandidateVerIter(Cache).Downloadable() == true)
+	    if (Cache[I].CandidateVer != 0 &&
+		 Cache[I].CandidateVerIter(Cache).Downloadable() == true)
 	       Cache.MarkInstall(I);
 	    else
 	       return _error->Error(_("The package %s needs to be reinstalled, "
@@ -246,7 +247,8 @@ bool pkgApplyStatus(pkgDepCache &Cache)
 	    Cache.MarkKeep(I);
 	 else
 	 {
-	    if (Cache[I].CandidateVerIter(Cache).Downloadable() == true)
+	    if (Cache[I].CandidateVer != 0 &&
+		 Cache[I].CandidateVerIter(Cache).Downloadable() == true)
 	       Cache.MarkInstall(I);
 	    else
 	       Cache.MarkDelete(I);

+ 2 - 2
cmdline/apt-cache.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: apt-cache.cc,v 1.53 2001/12/07 05:57:43 jgg Exp $
+// $Id: apt-cache.cc,v 1.54 2001/12/26 06:47:58 jgg Exp $
 /* ######################################################################
    
    apt-cache - Manages the cache files
@@ -1362,7 +1362,7 @@ int main(int argc,const char *argv[])
 
    if (CmdL.DispatchArg(CmdsA,false) == false && _error->PendingError() == false)
    { 
-      MMap *Map;
+      MMap *Map = 0;
       if (_config->FindB("APT::Cache::Generate",true) == false)
       {
 	 Map = new MMap(*new FileFd(_config->FindFile("Dir::Cache::pkgcache"),