Skip to content

Commit ee4771b

Browse files
hyung4kim-samsungGenkzsz11
authored andcommitted
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 Signed-off-by: DennySPb <dennyspb@gmail.com>
1 parent 5d3df5e commit ee4771b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

core/java/com/android/internal/os/WrapperInit.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,16 @@ public static void main(String[] args) {
6969
// Tell the Zygote what our actual PID is (since it only knows about the
7070
// wrapper that it directly forked).
7171
if (fdNum != 0) {
72+
FileDescriptor fd = new FileDescriptor();
7273
try {
73-
FileDescriptor fd = new FileDescriptor();
7474
fd.setInt$(fdNum);
7575
DataOutputStream os = new DataOutputStream(new FileOutputStream(fd));
7676
os.writeInt(Process.myPid());
7777
os.close();
78-
IoUtils.closeQuietly(fd);
7978
} catch (IOException ex) {
8079
Slog.d(TAG, "Could not write pid of wrapped process to Zygote pipe.", ex);
80+
} finally {
81+
IoUtils.closeQuietly(fd);
8182
}
8283
}
8384

0 commit comments

Comments
 (0)