summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2016-03-07 14:32:39 +0100
committerDimitri Staessens <[email protected]>2016-03-07 14:32:39 +0100
commita430220c4c7eb32dbd5236df4d335f3c017dcb8a (patch)
tree10808d3654e53170f4289c9ce31acfd670af3e16 /src
parent6df75c8d3c8b0c4820b930d5126620fd48b2c011 (diff)
parent17c2ec5c5c24b65321d9ad0207a269e54d25749e (diff)
downloadouroboros-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')
-rw-r--r--src/lib/du_buff.c5
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 {