diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-05-08 18:53:22 +0200 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-05-08 19:01:41 +0200 |
commit | 297843ec04385c0e3c6a81382582b8e95c79cafb (patch) | |
tree | 0e1c41ed3a61ef1a1f132990f4bacd44a45953ba /src | |
parent | 4e13c71204e9667cfc4b7da6491972f854d9402d (diff) | |
download | ouroboros-297843ec04385c0e3c6a81382582b8e95c79cafb.tar.gz ouroboros-297843ec04385c0e3c6a81382582b8e95c79cafb.zip |
lib: fixed enormous memory leak in shm_ap_rbuff
thanks Sander ;)
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/shm_ap_rbuff.c | 9 |
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; } |