From 86b378b810ab3bbcdb1427bdd86a7a4a4065fccd Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Wed, 5 May 2021 15:51:35 -0700 Subject: ANativeWindow_fromSurface: Use acquire not incStrong When we call incStrong like this, it won't work if the caller of ANativeWindow_fromSurface later calls ANativeWindow_release and so we leak the reference indefinitely. We change to call acquire so that the caller can call release. Bug: 186190571 Test: Existing tests pass Change-Id: I647a856923c891da2d305471f5ff84103d1f9ed5 --- native/android/native_window_jni.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/android/native_window_jni.cpp b/native/android/native_window_jni.cpp index 859c550db94d..901b4de4f13b 100644 --- a/native/android/native_window_jni.cpp +++ b/native/android/native_window_jni.cpp @@ -30,7 +30,7 @@ using namespace android; ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface) { sp win = android_view_Surface_getNativeWindow(env, surface); if (win != NULL) { - win->incStrong((void*)ANativeWindow_fromSurface); + ANativeWindow_acquire(win.get()); } return win.get(); } -- cgit v1.2.3-59-g8ed1b