diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-05-08 19:03:31 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-05-08 19:03:31 +0200 |
commit | d1b6d04ae9b0c43a8cdd79bec8d6495c0d671787 (patch) | |
tree | 0e1c41ed3a61ef1a1f132990f4bacd44a45953ba /src/lib/shm_ap_rbuff.c | |
parent | 4e80e06772a0896dcb0f9f6fa2e455e7542eac24 (diff) | |
parent | 297843ec04385c0e3c6a81382582b8e95c79cafb (diff) | |
download | ouroboros-d1b6d04ae9b0c43a8cdd79bec8d6495c0d671787.tar.gz ouroboros-d1b6d04ae9b0c43a8cdd79bec8d6495c0d671787.zip |
Merged in dstaesse/ouroboros/be-fast-path (pull request #67)
lib: fixed enormous memory leak in shm_ap_rbuff
Diffstat (limited to 'src/lib/shm_ap_rbuff.c')
-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; } |