Fix some memory/fd leaks for tag searching and empty account listing
authorChip Black <bytex64@bytex64.net>
Tue, 28 Dec 2010 04:03:13 +0000 (22:03 -0600)
committerChip Black <bytex64@bytex64.net>
Tue, 28 Dec 2010 04:03:13 +0000 (22:03 -0600)
http_blerg.c
tags.c

index 93d0984..73f88fe 100644 (file)
@@ -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 (file)
--- 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: