summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-01-14 17:29:12 +0800
committerChia-I Wu <[email protected]>2010-01-14 17:29:48 +0800
commit81430b95d094f81548b9256bc47a8912d9dfd245 (patch)
tree78937652fa626176464a736e7a2fe6e3c931cc38 /src/gallium/state_trackers
parent6cb89b23eeac50cfb0c5fb8d77e19f869b524eac (diff)
egl_g3d: Check if the creation of pipe or st context fails.
It should not return an incomplete EGLContext to the users.
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/egl_g3d/common/egl_g3d.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c
index 9d5734d46f9..8b69a8cfcb6 100644
--- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c
@@ -547,7 +547,7 @@ egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
_EGLContext *share, const EGLint *attribs)
{
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
- struct egl_g3d_context *xshare = egl_g3d_context(share);
+ struct egl_g3d_context *gshare = egl_g3d_context(share);
struct egl_g3d_config *gconf = egl_g3d_config(conf);
struct egl_g3d_context *gctx;
const __GLcontextModes *mode;
@@ -572,8 +572,18 @@ egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
mode = &gconf->native->mode;
gctx->pipe =
gdpy->native->create_context(gdpy->native, (void *) &gctx->base);
+ if (!gctx->pipe) {
+ free(gctx);
+ return NULL;
+ }
+
gctx->st_ctx = gctx->stapi->st_create_context(gctx->pipe, mode,
- (xshare) ? xshare->st_ctx : NULL);
+ (gshare) ? gshare->st_ctx : NULL);
+ if (!gctx->st_ctx) {
+ gctx->pipe->destroy(gctx->pipe);
+ free(gctx);
+ return NULL;
+ }
return &gctx->base;
}