Merge remote-tracking branch 'origin/patches-2.0'

This commit is contained in:
Nick Mathewson 2011-04-14 14:20:09 -04:00
commit d28fc52815
2 changed files with 7 additions and 5 deletions

View File

@ -4312,7 +4312,8 @@ evdns_getaddrinfo_gotresolve(int result, char type, int count,
evdns_cancel_request(NULL, other_req->r); evdns_cancel_request(NULL, other_req->r);
} }
data->user_cb(EVUTIL_EAI_MEMORY, NULL, data->user_data); data->user_cb(EVUTIL_EAI_MEMORY, NULL, data->user_data);
evutil_freeaddrinfo(res); if (res)
evutil_freeaddrinfo(res);
if (other_req->r == NULL) if (other_req->r == NULL)
free_getaddrinfo_request(data); free_getaddrinfo_request(data);

View File

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