Skip to content

Commit

Permalink
ASan: Fixed memory leak
Browse files Browse the repository at this point in the history
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  (<unknown module>)

SUMMARY: AddressSanitizer: 768 byte(s) leaked in 1 allocation(s).

Bug: None
Test: ./minijail0 (compiled with -fsanitize=address)
Change-Id: If01e1174b736f6d19abe3597318bed4dc3fb013a
  • Loading branch information
lhchavez authored and Treehugger Robot committed Sep 1, 2017
1 parent 24b64c2 commit 6c8d820
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion minijail0.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 6c8d820

Please sign in to comment.