From 6c8d820e761cb17e189eb7b33b9497ca2ff5aaa3 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Fri, 1 Sep 2017 03:55:11 +0000 Subject: [PATCH] ASan: Fixed memory leak This change frees the |struct minijail| in minijail0: ================================================================= ==31408==ERROR: LeakSanitizer: detected memory leaks Direct leak of 768 byte(s) in 1 object(s) allocated from: #0 0x7f69b789f79a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a) #1 0x4030cb in main minijail0.c:592 #2 0x7fffe06c1724 () SUMMARY: AddressSanitizer: 768 byte(s) leaked in 1 allocation(s). Bug: None Test: ./minijail0 (compiled with -fsanitize=address) Change-Id: If01e1174b736f6d19abe3597318bed4dc3fb013a --- minijail0.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/minijail0.c b/minijail0.c index 3e356ff..42f6149 100644 --- a/minijail0.c +++ b/minijail0.c @@ -628,5 +628,9 @@ int main(int argc, char *argv[]) info("not running init loop, exiting immediately"); return 0; } - return minijail_wait(j); + int ret = minijail_wait(j); +#if defined(__SANITIZE_ADDRESS__) + minijail_destroy(j); +#endif /* __SANITIZE_ADDRESS__ */ + return ret; }