Index: cygpackage.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/cygpackage.cc,v
retrieving revision 2.18
diff -p -u -r2.18 cygpackage.cc
--- cygpackage.cc	6 Aug 2006 22:09:26 -0000	2.18
+++ cygpackage.cc	23 Feb 2008 18:23:06 -0000
@@ -31,6 +31,7 @@ static const char *cvsid =
 
 #include "package_version.h"
 #include "cygpackage.h"
+#include "LogSingleton.h"
 
 /* this constructor creates an invalid package - further details MUST be provided */
 cygpackage::cygpackage ():
@@ -130,7 +131,11 @@ cygpackage::getfirstfile ()
   listdata = compress::decompress (listfile);
   if (!listdata)
     return std::string();
-  return listdata->gets (getfilenamebuffer, sizeof (getfilenamebuffer));
+  /* std::string(NULL) will crash, so be careful to test for that. */
+  const char *result = listdata->gets (getfilenamebuffer, sizeof (getfilenamebuffer));
+  if (result == NULL)
+    log (LOG_PLAIN) << "Corrupt package listing for " << name << ", can't uninstall old files." << endLog;
+  return std::string (result ? result : "");
 }
 
 const std::string
