From: Chip Black Date: Tue, 28 Dec 2010 04:03:13 +0000 (-0600) Subject: Fix some memory/fd leaks for tag searching and empty account listing X-Git-Tag: ohfuckreddit~36 X-Git-Url: http://git.bytex64.net/?a=commitdiff_plain;h=da5af7e043fdf8992ae30ac19f33446f8133f178;p=blerg.git Fix some memory/fd leaks for tag searching and empty account listing --- diff --git a/http_blerg.c b/http_blerg.c index 93d0984..73f88fe 100644 --- a/http_blerg.c +++ b/http_blerg.c @@ -359,6 +359,7 @@ ahc_derp (void *cls, struct MHD_Connection *connection, const char *url, const c uint64_t record_count, from, to; record_count = blerg_get_record_count(b); if (record_count == 0) { + blerg_close(b); response = MHD_create_response_from_data(2, "[]", MHD_NO, MHD_NO); } else { to = record_count - 1; @@ -367,8 +368,10 @@ ahc_derp (void *cls, struct MHD_Connection *connection, const char *url, const c } } - if (response == NULL) + if (response == NULL) { + blerg_close(b); return respond_JSON_Failure(connection); + } ret = MHD_queue_response(connection, MHD_HTTP_OK, response); MHD_destroy_response(response); diff --git a/tags.c b/tags.c index 1130d57..1911ac8 100644 --- a/tags.c +++ b/tags.c @@ -152,6 +152,7 @@ struct tag * tag_list(const char *tag, uint64_t offset, uint64_t *count, int dir } munmap(taglist, st.st_size); + close(tag_fd); return retlist; tag_list_malloc_failed: