From 52dda598963cefc82cfc5e55342ff631a07fd6d4 Mon Sep 17 00:00:00 2001 From: Andrew Rossignol Date: Tue, 9 Aug 2016 10:54:38 -0700 Subject: [PATCH] ContextHub: Avoid reference leaks The ContextHub HAL was leaking references in passOnOsResponse. An example of this is when a sensor hub reset occurs. If many of these resets happen, the local reference pool is exhausted and a crash in the HAL occurs. Bug: 30706325 Change-Id: Ica5328137a7033f512d7fb1ccf6fa138eab55091 --- core/jni/android_hardware_location_ContextHubService.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/jni/android_hardware_location_ContextHubService.cpp b/core/jni/android_hardware_location_ContextHubService.cpp index 9515a0e336aa5..7a8a574b119e3 100644 --- a/core/jni/android_hardware_location_ContextHubService.cpp +++ b/core/jni/android_hardware_location_ContextHubService.cpp @@ -603,6 +603,8 @@ static void passOnOsResponse(uint32_t hubHandle, uint32_t msgType, env->CallIntMethod(db.jniInfo.jContextHubService, db.jniInfo.contextHubServiceMsgReceiptCallback, jheader, jmsg); + env->DeleteLocalRef(jmsg); + env->DeleteLocalRef(jheader); delete[] msg; }