check for conf.error_handler before using it
[project/uhttpd.git] / file.c
diff --git a/file.c b/file.c
index 5de96f8..b2e6ade 100644 (file)
--- a/file.c
+++ b/file.c
@@ -176,6 +176,9 @@ uh_path_lookup(struct client *cl, const char *url)
                exists = !!canonpath(uh_buf, path_phys);
                uh_buf[i] = ch;
 
+               if (!exists)
+                       continue;
+
                snprintf(path_info, sizeof(path_info), "%s", uh_buf + i);
                break;
        }
@@ -696,10 +699,12 @@ void uh_handle_request(struct client *cl)
        if (__handle_file_request(cl, url))
                return;
 
-       error_handler = alloca(strlen(conf.error_handler) + 1);
-       strcpy(error_handler, conf.error_handler);
-       if (__handle_file_request(cl, error_handler))
-               return;
+       if (conf.error_handler) {
+               error_handler = alloca(strlen(conf.error_handler) + 1);
+               strcpy(error_handler, conf.error_handler);
+               if (__handle_file_request(cl, error_handler))
+                       return;
+       }
 
        uh_client_error(cl, 404, "Not Found", "The requested URL %s was not found on this server.", url);
 }