Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86b378b8 authored by Robert Carr's avatar Robert Carr
Browse files

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
parent 0e4d7f14
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ using namespace android;
ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface) {
    sp<ANativeWindow> win = android_view_Surface_getNativeWindow(env, surface);
    if (win != NULL) {
        win->incStrong((void*)ANativeWindow_fromSurface);
        ANativeWindow_acquire(win.get());
    }
    return win.get();
}