From ffbb4c9f7c2f73d2d1e585f022b18b224d727d36 Mon Sep 17 00:00:00 2001 From: Emil Mikulic Date: Sun, 28 Apr 2013 21:39:43 +1000 Subject: [PATCH] Fix memory leak when diropen() fails. Found by: clang static analyzer. --- darkhttpd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/darkhttpd.c b/darkhttpd.c index e1209d2..620c7ea 100644 --- a/darkhttpd.c +++ b/darkhttpd.c @@ -1611,7 +1611,7 @@ static void generate_dir_listing(struct connection *conn, const char *path) { ssize_t listsize; size_t maxlen = 2; /* There has to be ".." */ int i; - struct apbuf *listing = make_apbuf(); + struct apbuf *listing; listsize = make_sorted_dirlist(path, &list); if (listsize == -1) { @@ -1626,6 +1626,7 @@ static void generate_dir_listing(struct connection *conn, const char *path) { maxlen = tmp; } + listing = make_apbuf(); append(listing, "\n\n "); append(listing, conn->url); append(listing, "\n\n\n

");