Fixed Handler Leak on WrapperInit

Handler is not closed by IOException

Detected by static analysis

Test: Manual

Signed-off-by: hyung4.kim <hyung4.kim@samsung.com>
Change-Id: I702387572dafbd6cbd3ed2c2ecb71760b2725fe8
This commit is contained in:
hyung4.kim
2020-11-12 13:58:10 +09:00
parent 3acec4d14f
commit ec5cada58c

View File

@@ -69,15 +69,16 @@ public class WrapperInit {
// Tell the Zygote what our actual PID is (since it only knows about the
// wrapper that it directly forked).
if (fdNum != 0) {
FileDescriptor fd = new FileDescriptor();
try {
FileDescriptor fd = new FileDescriptor();
fd.setInt$(fdNum);
DataOutputStream os = new DataOutputStream(new FileOutputStream(fd));
os.writeInt(Process.myPid());
os.close();
IoUtils.closeQuietly(fd);
} catch (IOException ex) {
Slog.d(TAG, "Could not write pid of wrapped process to Zygote pipe.", ex);
} finally {
IoUtils.closeQuietly(fd);
}
}