Mesa (7.10): glx: Put null check before use

Ian Romanick idr at kemper.freedesktop.org
Tue Mar 1 00:01:37 UTC 2011


Module: Mesa
Branch: 7.10
Commit: d7d55ab8418c79c51207149d8982cd5e0990427c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d7d55ab8418c79c51207149d8982cd5e0990427c

Author: nobled <nobled at dreamwidth.org>
Date:   Thu Aug 19 14:06:21 2010 -0400

glx: Put null check before use

'dpy' was being checked for null *after* it was already used once.

Also add a null check for psc, and drop gc's redundant initialization.
(cherry picked from commit b5dc40710d0e5edffb9f673dfbf26df4d0043eef)

---

 src/glx/glxcmds.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index 4f7e84e..d9ca3f5 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -214,12 +214,16 @@ CreateContext(Display * dpy, int generic_id,
               Bool allowDirect,
 	      unsigned code, int renderType, int screen)
 {
-   struct glx_context *gc = NULL;
-   struct glx_screen *const psc = GetGLXScreenConfigs(dpy, screen);
+   struct glx_context *gc;
+   struct glx_screen *psc;
    struct glx_context *shareList = (struct glx_context *) shareList_user;
    if (dpy == NULL)
       return NULL;
 
+   psc = GetGLXScreenConfigs(dpy, screen);
+   if (psc == NULL)
+      return NULL;
+
    if (generic_id == None)
       return NULL;
 




More information about the mesa-commit mailing list