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

Commit 10e9ab50 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

check that the NativeWindowType is valid in eglCreateWindowSurface

This will avoid certain crash (null dereference),
and return an error instead. This is useful for
app developers as java language apps are not
expected to crash when passed bad arguments

This doesn’t fix bug 36065206, but was prompted
by it.

Test: compile / run
Bug: 36065206
Change-Id: I90d25730b3dd292d756b4c38b51320a466fa6d48
parent 56a8f942
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -836,6 +836,10 @@ int Surface::query(int what, int* value) const {
                *value = mFrameTimestampsSupportsRetire ? 1 : 0;
                *value = mFrameTimestampsSupportsRetire ? 1 : 0;
                return NO_ERROR;
                return NO_ERROR;
            }
            }
            case NATIVE_WINDOW_IS_VALID: {
                *value = mGraphicBufferProducer != nullptr ? 1 : 0;
                return NO_ERROR;
            }
        }
        }
    }
    }
    return mGraphicBufferProducer->query(what, value);
    return mGraphicBufferProducer->query(what, value);
+10 −0
Original line number Original line Diff line number Diff line
@@ -478,6 +478,16 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
    if (dp) {
    if (dp) {
        EGLDisplay iDpy = dp->disp.dpy;
        EGLDisplay iDpy = dp->disp.dpy;


        if (!window) {
            return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
        }

        int value = 0;
        window->query(window, NATIVE_WINDOW_IS_VALID, &value);
        if (!value) {
            return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
        }

        int result = native_window_api_connect(window, NATIVE_WINDOW_API_EGL);
        int result = native_window_api_connect(window, NATIVE_WINDOW_API_EGL);
        if (result != OK) {
        if (result != OK) {
            ALOGE("eglCreateWindowSurface: native_window_api_connect (win=%p) "
            ALOGE("eglCreateWindowSurface: native_window_api_connect (win=%p) "