summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2018-05-25 18:10:19 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2018-05-27 15:25:58 +0200
commit0a80c263488bbc7b9419f8cba14f3adeedba0383 (patch)
tree73e687634db84b6dcece8a924be87ff4fd81d7e7 /src/lib
parent35b18cd6879e730f150dd2aacf761a00eeb4615f (diff)
downloadouroboros-0a80c263488bbc7b9419f8cba14f3adeedba0383.tar.gz
ouroboros-0a80c263488bbc7b9419f8cba14f3adeedba0383.zip
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 <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/shm_rdrbuff.c6
1 files 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()