diff options
author | Dave Airlie <airlied@redhat.com> | 2008-04-24 16:37:29 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2008-04-24 16:58:14 +1000 |
commit | 947419bce25e6f003c74ba72a33ee6145396d1d8 (patch) | |
tree | be84e10d2c99b42840ea4444e4d496e10445f901 | |
parent | d7db6dd1a15393e9a30acfe87f7651ca1c9a0d75 (diff) |
glx: test for valid read and draw privates before using them
this should fix a bug where f-spot exiting blows up the X server
(cherry picked from commit ae982a27e4059fecd4048d245e6aa02f8dcc97d0)
-rw-r--r-- | GL/glx/glxutil.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/GL/glx/glxutil.c b/GL/glx/glxutil.c index 11e9f898b..aa23a95fd 100644 --- a/GL/glx/glxutil.c +++ b/GL/glx/glxutil.c @@ -81,38 +81,40 @@ __glXDeassociateContext(__GLXcontext *glxc) __GLXcontext *curr, *prev; prev = NULL; - for ( curr = glxc->drawPriv->drawGlxc - ; curr != NULL - ; prev = curr, curr = curr->nextDrawPriv ) { - if (curr == glxc) { - /* found context. Deassociate. */ - if (prev == NULL) { - glxc->drawPriv->drawGlxc = curr->nextDrawPriv; - } else { - prev->nextDrawPriv = curr->nextDrawPriv; + if (glxc->drawPriv) { + for ( curr = glxc->drawPriv->drawGlxc; curr != NULL + ; prev = curr, curr = curr->nextDrawPriv ) { + if (curr == glxc) { + /* found context. Deassociate. */ + if (prev == NULL) { + glxc->drawPriv->drawGlxc = curr->nextDrawPriv; + } else { + prev->nextDrawPriv = curr->nextDrawPriv; + } + curr->nextDrawPriv = NULL; + __glXUnrefDrawable(glxc->drawPriv); + break; } - curr->nextDrawPriv = NULL; - __glXUnrefDrawable(glxc->drawPriv); - break; - } + } } - prev = NULL; - for ( curr = glxc->readPriv->readGlxc - ; curr != NULL - ; prev = curr, curr = curr->nextReadPriv ) { - if (curr == glxc) { - /* found context. Deassociate. */ - if (prev == NULL) { - glxc->readPriv->readGlxc = curr->nextReadPriv; - } else { - prev->nextReadPriv = curr->nextReadPriv; - } - curr->nextReadPriv = NULL; - __glXUnrefDrawable(glxc->readPriv); - break; - } + if (glxc->readPriv) { + for ( curr = glxc->readPriv->readGlxc + ; curr != NULL + ; prev = curr, curr = curr->nextReadPriv ) { + if (curr == glxc) { + /* found context. Deassociate. */ + if (prev == NULL) { + glxc->readPriv->readGlxc = curr->nextReadPriv; + } else { + prev->nextReadPriv = curr->nextReadPriv; + } + curr->nextReadPriv = NULL; + __glXUnrefDrawable(glxc->readPriv); + break; + } + } } } |