From 297843ec04385c0e3c6a81382582b8e95c79cafb Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Sun, 8 May 2016 18:53:22 +0200 Subject: lib: fixed enormous memory leak in shm_ap_rbuff thanks Sander ;) --- src/lib/shm_ap_rbuff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/lib') 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; } -- cgit v1.2.3