--- pan.orig/pan.c	2008-05-19 15:22:45.000000000 +0800
+++ pan/pan.c	2008-05-19 20:56:03.000000000 +0800
@@ -321,6 +321,8 @@ main(int argc, char **argv)
     }
 
     coll = get_collection(filename, optind, argc, argv);
+    if(!coll)
+        exit(1);
     if (coll->cnt == 0) {
 	fprintf(stderr,
 		"pan(%s): Must supply a file collection or a command\n",
@@ -577,7 +579,7 @@ main(int argc, char **argv)
 	++exit_stat;
     }
     fclose(zoofile);
-	if (fmt_print)
+	if (logfile && fmt_print)
 	{
 		if (uname(&unamebuf) == -1)
 			fprintf(stderr, "ERROR: uname(): %s\n", strerror(errno));
@@ -1017,6 +1019,8 @@ get_collection(char *file, int optind, i
     int i;
 
     buf = slurp(file);
+    if(!buf)
+        return NULL;
 
     coll = (struct collection *) malloc(sizeof(struct collection));
     coll->cnt = 0;
