1be407
diff -upr man-db-2.6.2.orig/src/check_mandirs.c man-db-2.6.2/src/check_mandirs.c
1be407
--- man-db-2.6.2.orig/src/check_mandirs.c	2011-07-09 20:53:38.000000000 +0200
1be407
+++ man-db-2.6.2/src/check_mandirs.c	2012-07-31 13:05:45.967640117 +0200
1be407
@@ -190,8 +190,7 @@ void test_manfile (const char *file, con
1be407
 			   comp extensions */
1be407
 			abs_filename = make_filename (path, NULL,
1be407
 						      exists, "man");
1be407
-			debug ("test_manfile(): stat %s\n", abs_filename);
1be407
-			if (stat (abs_filename, &physical) == -1) {
1be407
+			if (abs_filename == NULL || stat (abs_filename, &physical) == -1) {
1be407
 				if (!opt_test)
1be407
 					dbdelete (manpage_base, exists);
1be407
 			} else {
1be407
diff -upr man-db-2.6.2.orig/src/filenames.c man-db-2.6.2/src/filenames.c
1be407
--- man-db-2.6.2.orig/src/filenames.c	2011-10-09 01:19:00.000000000 +0200
1be407
+++ man-db-2.6.2/src/filenames.c	2012-07-31 12:31:10.436885216 +0200
1be407
@@ -27,6 +27,7 @@
1be407
 
1be407
 #include <string.h>
1be407
 #include <stdlib.h>
1be407
+#include <unistd.h>
1be407
 
1be407
 #include "xvasprintf.h"
1be407
 
1be407
@@ -61,6 +62,11 @@ char *make_filename (const char *path, c
1be407
 	if (in->comp && *in->comp != '-')	/* Is there an extension? */
1be407
 		file = appendstr (file, ".", in->comp, NULL);
1be407
 
1be407
+	if (access (file, R_OK) != 0) {
1be407
+		free (file);
1be407
+		return NULL;
1be407
+	}
1be407
+
1be407
 	return file;
1be407
 }
1be407
 
1be407
diff -upr man-db-2.6.2.orig/src/man.c man-db-2.6.2/src/man.c
1be407
--- man-db-2.6.2.orig/src/man.c	2012-05-15 01:24:17.000000000 +0200
1be407
+++ man-db-2.6.2/src/man.c	2012-07-31 13:04:48.629069419 +0200
1be407
@@ -3103,6 +3103,9 @@ static int add_candidate (struct candida
1be407
 			name = req_name;
1be407
 
1be407
 		filename = make_filename (path, name, source, cat ? "cat" : "man");
1be407
+		if (filename == NULL) {
1be407
+			return 0;
1be407
+		}
1be407
 		ult = ult_src (filename, path, NULL,
1be407
 			       get_ult_flags (from_db, source->id), NULL);
1be407
 		free (filename);
1be407
@@ -3309,6 +3312,9 @@ static int display_filesystem (struct ca
1be407
 {
1be407
 	char *filename = make_filename (candp->path, NULL, candp->source,
1be407
 					candp->cat ? "cat" : "man");
1be407
+	if (filename == NULL) {
1be407
+		return 0;
1be407
+	}
1be407
 	/* source->name is never NULL thanks to add_candidate() */
1be407
 	char *title = appendstr (NULL, candp->source->name,
1be407
 				 "(", candp->source->ext, ")", NULL);
1be407
@@ -3392,14 +3398,14 @@ static int display_database (struct cand
1be407
 
1be407
 	if (in->id < STRAY_CAT) {	/* There should be a src page */
1be407
 		file = make_filename (candp->path, name, in, "man");
1be407
-		debug ("Checking physical location: %s\n", file);
1be407
+		if (file != NULL) {
1be407
+			debug ("Checking physical location: %s\n", file);
1be407
 
1be407
-		if (access (file, R_OK) == 0) {
1be407
 			const char *man_file;
1be407
 			char *cat_file;
1be407
 
1be407
 			man_file = ult_src (file, candp->path, NULL,
1be407
-					    get_ult_flags (1, in->id), NULL);
1be407
+						get_ult_flags (1, in->id), NULL);
1be407
 			if (man_file == NULL) {
1be407
 				free (title);
1be407
 				return found; /* zero */
1be407
@@ -3416,7 +3422,7 @@ static int display_database (struct cand
1be407
 			free (lang);
1be407
 			lang = NULL;
1be407
 		} /* else {drop through to the bottom and return 0 anyway} */
1be407
-	} else 
1be407
+	} else
1be407
 
1be407
 #endif /* NROFF_MISSING */
1be407
 
1be407
@@ -3441,9 +3447,9 @@ static int display_database (struct cand
1be407
 		}
1be407
 
1be407
 		file = make_filename (candp->path, name, in, "cat");
1be407
-		debug ("Checking physical location: %s\n", file);
1be407
-
1be407
-		if (access (file, R_OK) != 0) {
1be407
+		if (file != NULL) {
1be407
+			debug ("Checking physical location: %s\n", file);
1be407
+		} else {
1be407
 			char *catpath;
1be407
 			catpath = get_catpath (candp->path,
1be407
 					       global_manpath ? SYSTEM_CAT
1be407
@@ -3453,10 +3459,10 @@ static int display_database (struct cand
1be407
 				file = make_filename (catpath, name,
1be407
 						      in, "cat");
1be407
 				free (catpath);
1be407
-				debug ("Checking physical location: %s\n",
1be407
-				       file);
1be407
-
1be407
-				if (access (file, R_OK) != 0) {
1be407
+				if (file != NULL) {
1be407
+					debug ("Checking physical location: %s\n",
1be407
+						   file);
1be407
+				} else {
1be407
 					/* don't delete here, 
1be407
 					   return==0 will do that */
1be407
 					free (title);
1be407
@@ -3520,6 +3526,8 @@ static int maybe_update_file (const char
1be407
 		real_name = name;
1be407
 
1be407
 	file = make_filename (manpath, real_name, info, "man");
1be407
+	if (file == NULL)
1be407
+		return 0;
1be407
 	if (lstat (file, &buf) != 0)
1be407
 		return 0;
1be407
 	if (buf.st_mtime == info->_st_mtime)