diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 9167b9b7eed..ae356e8d87b 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -559,14 +559,14 @@ _eglQuerySurface(_EGLDisplay *disp, _EGLSurface *surface, return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); _EGLContext *ctx = _eglGetCurrentContext(); - EGLint result = disp->Driver->QueryBufferAge(disp, surface); - /* error happened */ - if (result < 0) - return EGL_FALSE; if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || ctx->DrawSurface != surface) return _eglError(EGL_BAD_SURFACE, "eglQuerySurface"); + EGLint result = disp->Driver->QueryBufferAge(disp, surface); + if (result < 0) + return EGL_FALSE; + *value = result; surface->BufferAgeRead = EGL_TRUE; break;