summaryrefslogtreecommitdiffstats
path: root/services/jni
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-03-27 19:35:43 -0700
committerMike Lockwood <lockwood@android.com>2011-03-27 19:35:43 -0700
commit8f8c6023f2fad38347cd19af9a81fa485fe3bd82 (patch)
treeb455948bf249e2a63e1552ad50530dc1a2c8222d /services/jni
parent0b9bacc69314fc6480d1ebe67b7ee0d0aebca5c0 (diff)
downloadframeworks_base-8f8c6023f2fad38347cd19af9a81fa485fe3bd82.zip
frameworks_base-8f8c6023f2fad38347cd19af9a81fa485fe3bd82.tar.gz
frameworks_base-8f8c6023f2fad38347cd19af9a81fa485fe3bd82.tar.bz2
UsbService: Fix JNI local reference leaks in the USB host support code
Bug: 4175857 Change-Id: I8b385f2257e509b0fb4d5f9516e9813b8165352d Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'services/jni')
-rw-r--r--services/jni/com_android_server_UsbService.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/services/jni/com_android_server_UsbService.cpp b/services/jni/com_android_server_UsbService.cpp
index 816f76f..6aeede2 100644
--- a/services/jni/com_android_server_UsbService.cpp
+++ b/services/jni/com_android_server_UsbService.cpp
@@ -117,9 +117,14 @@ static int usb_device_added(const char *devname, void* client_data) {
jintArray endpointArray = env->NewIntArray(length);
env->SetIntArrayRegion(endpointArray, 0, length, endpointValues.array());
+ jstring deviceName = env->NewStringUTF(devname);
env->CallVoidMethod(thiz, method_usbDeviceAdded,
- env->NewStringUTF(devname), vendorId, productId, deviceClass,
+ deviceName, vendorId, productId, deviceClass,
deviceSubClass, protocol, interfaceArray, endpointArray);
+
+ env->DeleteLocalRef(interfaceArray);
+ env->DeleteLocalRef(endpointArray);
+ env->DeleteLocalRef(deviceName);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
return 0;
@@ -129,7 +134,9 @@ static int usb_device_removed(const char *devname, void* client_data) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
jobject thiz = (jobject)client_data;
+ jstring deviceName = env->NewStringUTF(devname);
env->CallVoidMethod(thiz, method_usbDeviceRemoved, env->NewStringUTF(devname));
+ env->DeleteLocalRef(deviceName);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
return 0;
}