I think I see the problem; I forgot that PkgFileIterator::Archive can return 
NULL (I suppose this is to handle packages from archives without a Release 
file?).  The attached patch fixes this crash and a similar one in 'aptitude 
show'.

  Daniel

-- 
/------------------- Daniel Burrows <[EMAIL PROTECTED]> ------------------\
|                Voodoo Programming: Things programmers do                  |
|                that they know shouldn't work but they try                 |
|                anyway, and which sometimes actually work,                 |
|                such as recompiling everything.                            |
\--------------------- A duck! -- http://www.python.org --------------------/
Index: src/cmdline/cmdline_show.cc
===================================================================
--- src/cmdline/cmdline_show.cc	(revision 3386)
+++ src/cmdline/cmdline_show.cc	(working copy)
@@ -114,7 +114,12 @@
   vector<fragment *> fragments;
 
   for( ; !vf.end(); ++vf)
-    fragments.push_back(text_fragment(vf.File().Archive()));
+    {
+      if(vf.File().Archive() == 0)
+	fragments.push_back(text_fragment(_("<NULL>")));
+      else
+	fragments.push_back(text_fragment(vf.File().Archive()));
+    }
 
   if(fragments.size()==0)
     return fragf("");
@@ -296,7 +301,9 @@
       if(verbose<2) // Show all archives in a list.
 	fragments.push_back(archive_lst_frag(ver.FileList(), _("Archive")));
       else
-	fragments.push_back(fragf("%s: %s%n", _("Archive"), vf.File().Archive()));
+	{
+	  fragments.push_back(fragf("%s: %s%n", _("Archive"), vf.File().Archive()?vf.File().Archive():_("<NULL>")));
+	}
     }
 
   fragments.push_back(dep_lst_frag(ver.DependsList(),
Index: src/solution_fragment.cc
===================================================================
--- src/solution_fragment.cc	(revision 3386)
+++ src/solution_fragment.cc	(working copy)
@@ -58,7 +58,12 @@
   vector<fragment *> archive_fragments;
 
   for(pkgCache::VerFileIterator vf=v.FileList(); !vf.end(); ++vf)
-    archive_fragments.push_back(text_fragment(vf.File().Archive()));
+    {
+      if(vf.File().Archive())
+	archive_fragments.push_back(text_fragment(vf.File().Archive()));
+      else
+	archive_fragments.push_back(text_fragment(_("<NULL>")));
+    }
 
   return join_fragments(archive_fragments, ",");
 }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 3391)
+++ ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2005-06-08  Daniel Burrows  <[EMAIL PROTECTED]>
+
+	* src/cmdline/cmdline_show.cc, src/solution_fragment.cc:
+
+	Fix several places where aptitude could crash because I forgot
+	that PkgFileIterator::Archive can return a NULL pointer.
+	(Closes: #312553)
+
 2005-06-07  Daniel Burrows  <[EMAIL PROTECTED]>
 
 	* src/vscreen/vs_util.cc:

Attachment: pgp4vXxIuErRC.pgp
Description: PGP signature

Reply via email to