static void
send_document_cb(struct evhttp_request *req, void *arg)
{
- struct evbuffer *evb;
+ struct evbuffer *evb = NULL;
const char *docroot = arg;
const char *uri = evhttp_request_get_uri(req);
struct evhttp_uri *decoded = NULL;
if (!(d = opendir(whole_path)))
goto err;
#endif
- close(fd);
evbuffer_add_printf(evb, "<html>\n <head>\n"
" <title>%s</title>\n"
}
evhttp_send_reply(req, 200, "OK", evb);
- evbuffer_free(evb);
- return;
+ goto done;
err:
evhttp_send_error(req, 404, "Document was not found");
if (fd>=0)
close(fd);
+done:
if (decoded)
evhttp_uri_free(decoded);
if (decoded_path)
free(decoded_path);
if (whole_path)
free(whole_path);
+ if (evb)
+ evbuffer_free(evb);
}
static void