From 0a80c263488bbc7b9419f8cba14f3adeedba0383 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 25 May 2018 18:10:19 +0200 Subject: lib: Fix potential memleak in rdrbuff The rdrb struct should be freed when destroying the rdrbuff, even when the actual shared memory is not unlinked. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/shm_rdrbuff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/shm_rdrbuff.c b/src/lib/shm_rdrbuff.c index 12e29bef..bbad361a 100644 --- a/src/lib/shm_rdrbuff.c +++ b/src/lib/shm_rdrbuff.c @@ -148,8 +148,10 @@ void shm_rdrbuff_destroy(struct shm_rdrbuff * rdrb) assert(rdrb); - if (getpid() != *rdrb->pid && kill(*rdrb->pid, 0) == 0) + if (getpid() != *rdrb->pid && kill(*rdrb->pid, 0) == 0) { + free(rdrb); return; + } shm_rdrbuff_close(rdrb); @@ -275,7 +277,7 @@ struct shm_rdrbuff * shm_rdrbuff_create() fail_mattr: shm_rdrbuff_destroy(rdrb); fail_rdrb: - return NULL; + return NULL; } struct shm_rdrbuff * shm_rdrbuff_open() -- cgit v1.2.3