summaryrefslogtreecommitdiff
path: root/src/lib/du_buff.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@intec.ugent.be>2016-03-04 10:24:11 +0100
committerDimitri Staessens <dimitri.staessens@intec.ugent.be>2016-03-04 10:24:11 +0100
commit17c2ec5c5c24b65321d9ad0207a269e54d25749e (patch)
tree10808d3654e53170f4289c9ce31acfd670af3e16 /src/lib/du_buff.c
parent6df75c8d3c8b0c4820b930d5126620fd48b2c011 (diff)
downloadouroboros-17c2ec5c5c24b65321d9ad0207a269e54d25749e.tar.gz
ouroboros-17c2ec5c5c24b65321d9ad0207a269e54d25749e.zip
lib: fixed memory leaks in du_buff
du_buff.c: memory leak fixes
Diffstat (limited to 'src/lib/du_buff.c')
-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 {