libminijail.c: fix dangling pointer evaluation on unmarshal error

If minijail_unmarshal fails, the process will still need to call
minijail_destroy to free up any allocated memory.  The unmarshalling
function exits immediately on error. That property means that some
stale pointers may still exist.

This change adds pointer clearing on error and fixes a minor memory
leak of the chrootdir.

BUG=none
TEST=compiles and running ./libminijail_unittest passes. Still need to run the autotest suite on it.

Change-Id: I47518130aef7f4a14e5da475ed6a84c2d1490940
Reviewed-on: https://gerrit.chromium.org/gerrit/10535
Commit-Ready: Will Drewry <wad@chromium.org>
Reviewed-by: Will Drewry <wad@chromium.org>
Tested-by: Will Drewry <wad@chromium.org>
1 file changed