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

Eric Anholt anholt at kemper.freedesktop.org
Sat Feb 12 02:22:05 UTC 2011


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

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.

---

 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 d12ff96..80eaf72 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -215,12 +215,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