diff options
author | Dimitri Staessens <dimitri.staessens@intec.ugent.be> | 2016-03-07 14:32:39 +0100 |
---|---|---|
committer | Dimitri Staessens <dimitri.staessens@intec.ugent.be> | 2016-03-07 14:32:39 +0100 |
commit | a430220c4c7eb32dbd5236df4d335f3c017dcb8a (patch) | |
tree | 10808d3654e53170f4289c9ce31acfd670af3e16 /src/lib | |
parent | 6df75c8d3c8b0c4820b930d5126620fd48b2c011 (diff) | |
parent | 17c2ec5c5c24b65321d9ad0207a269e54d25749e (diff) | |
download | ouroboros-a430220c4c7eb32dbd5236df4d335f3c017dcb8a.tar.gz ouroboros-a430220c4c7eb32dbd5236df4d335f3c017dcb8a.zip |
Merged in dstaesse/ouroboros/be (pull request #21)
lib: fixed memory leaks in du_buff
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/du_buff.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/du_buff.c b/src/lib/du_buff.c index bfb33339..08e3d23e 100644 --- a/src/lib/du_buff.c +++ b/src/lib/du_buff.c @@ -85,6 +85,9 @@ struct buffer * buffer_create (size_t size, size_t headspace, size_t len) bool head_block = true; head = malloc(sizeof *head); + if (head == NULL) + return NULL; + head->size=0; head->data=NULL; @@ -111,6 +114,7 @@ struct buffer * buffer_create (size_t size, size_t headspace, size_t len) buf = malloc(sizeof *buf); if (buf == NULL) { LOG_WARN("Could not allocate struct."); + free(head); return NULL; } @@ -119,6 +123,7 @@ struct buffer * buffer_create (size_t size, size_t headspace, size_t len) if (buf->data == NULL) { LOG_WARN("Could not allocate memory block."); buffer_destroy_list(head); + free(head); return NULL; } } else { |