From 7bcb9597c8ae90e22ee9efff6f64cf3e2065e5dc Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Mon, 13 Jul 2015 18:00:35 -0700 Subject: [PATCH] Fix BluetoothSocket file descriptor leak Sockets accepted on a server socket didn't populate the mPfd field, which is used to close out the java end of the native-and-java communication socket when the overall rfcomm socket is closed. #badnewsbears b/21398841 Change-Id: I3adb0a9965f83d0f3006fa4f79ea4abeab5c9a17 --- core/java/android/bluetooth/BluetoothSocket.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/java/android/bluetooth/BluetoothSocket.java b/core/java/android/bluetooth/BluetoothSocket.java index 36997e544841f..386a1e0d16961 100644 --- a/core/java/android/bluetooth/BluetoothSocket.java +++ b/core/java/android/bluetooth/BluetoothSocket.java @@ -191,6 +191,8 @@ public final class BluetoothSocket implements Closeable { as.close(); throw new IOException("bt socket acept failed"); } + + as.mPfd = new ParcelFileDescriptor(fds[0]); as.mSocket = new LocalSocket(fds[0]); as.mSocketIS = as.mSocket.getInputStream(); as.mSocketOS = as.mSocket.getOutputStream();