summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-08 18:53:22 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-08 19:01:41 +0200
commit297843ec04385c0e3c6a81382582b8e95c79cafb (patch)
tree0e1c41ed3a61ef1a1f132990f4bacd44a45953ba
parent4e13c71204e9667cfc4b7da6491972f854d9402d (diff)
downloadouroboros-297843ec04385c0e3c6a81382582b8e95c79cafb.tar.gz
ouroboros-297843ec04385c0e3c6a81382582b8e95c79cafb.zip
lib: fixed enormous memory leak in shm_ap_rbuff
thanks Sander ;)
-rw-r--r--src/lib/shm_ap_rbuff.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c
index 0a41dfb3..34583d8e 100644
--- a/src/lib/shm_ap_rbuff.c
+++ b/src/lib/shm_ap_rbuff.c
@@ -244,17 +244,20 @@ int shm_ap_rbuff_write(struct shm_ap_rbuff * rb, struct rb_entry * e)
}
struct rb_entry * shm_ap_rbuff_read(struct shm_ap_rbuff * rb)
{
- struct rb_entry * e = malloc(sizeof(*e));
- if (e == NULL)
- return NULL;
+ struct rb_entry * e = NULL;
if (rb == NULL)
return NULL;
+ e = malloc(sizeof(*e));
+ if (e == NULL)
+ return NULL;
+
pthread_mutex_lock(rb->shm_mutex);
if (shm_rbuff_used(rb) == 0) {
pthread_mutex_unlock(rb->shm_mutex);
+ free(e);
return NULL;
}