diff options
author | Nicolai Hähnle <[email protected]> | 2017-02-02 18:06:27 +0100 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2017-02-06 17:39:30 +0100 |
commit | f446f3fb33528eebe9b120340fca3ac5c5ba518d (patch) | |
tree | 9c4c5a1da5da416a7e1e7bc9e0bfad6f0c6cb417 /src/glx/glxcmds.c | |
parent | 21ec35566be2c1aca07083a67f462618ae15fa86 (diff) |
glx: guard swap-interval functions against destroyed drawables
The GLX specification says about glXDestroyPixmap:
"The storage for the GLX pixmap will be freed when it is not current
to any client."
So arguably, functions like glXSwapIntervalMESA can be called after
glXDestroyPixmap has been called for the currently bound GLXPixmap.
In that case, the GLXDRIDrawable no longer exists, and so we just skip
those calls.
Cc: 17.0 <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/glx/glxcmds.c')
-rw-r--r-- | src/glx/glxcmds.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 6c7bbfd5d1c..53c9f9ce2af 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -1761,7 +1761,11 @@ __glXSwapIntervalSGI(int interval) psc->driScreen->setSwapInterval) { __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable); - psc->driScreen->setSwapInterval(pdraw, interval); + /* Simply ignore the command if the GLX drawable has been destroyed but + * the context is still bound. + */ + if (pdraw) + psc->driScreen->setSwapInterval(pdraw, interval); return 0; } #endif @@ -1807,7 +1811,14 @@ __glXSwapIntervalMESA(unsigned int interval) if (psc && psc->driScreen && psc->driScreen->setSwapInterval) { __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable); - return psc->driScreen->setSwapInterval(pdraw, interval); + + /* Simply ignore the command if the GLX drawable has been destroyed but + * the context is still bound. + */ + if (!pdraw) + return 0; + + return psc->driScreen->setSwapInterval(pdraw, interval); } } #endif @@ -1829,7 +1840,8 @@ __glXGetSwapIntervalMESA(void) if (psc && psc->driScreen && psc->driScreen->getSwapInterval) { __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable); - return psc->driScreen->getSwapInterval(pdraw); + if (pdraw) + return psc->driScreen->getSwapInterval(pdraw); } } #endif |