Make sure drivers don't dereference a NULL pointer if
authorIan Romanick <idr@us.ibm.com>
Fri, 26 Mar 2004 02:02:48 +0000 (02:02 +0000)
committerIan Romanick <idr@us.ibm.com>
Fri, 26 Mar 2004 02:02:48 +0000 (02:02 +0000)
__driUtilCreateNewScreen returns NULL.

src/mesa/drivers/dri/i810/i810screen.c
src/mesa/drivers/dri/mach64/mach64_screen.c
src/mesa/drivers/dri/mga/mga_xmesa.c
src/mesa/drivers/dri/r200/r200_screen.c
src/mesa/drivers/dri/radeon/radeon_screen.c

index 232f62d41d8ee2a4ac221d5a603e436802229dc7..a095b28add1b280d98981a2237eef34d3267d395 100644 (file)
@@ -439,14 +439,14 @@ void * __driCreateNewScreen( Display *dpy, int scrn, __DRIscreen *psc,
                                  ddx_version, dri_version, drm_version,
                                  frame_buffer, pSAREA, fd,
                                  internal_api_version, &i810API);
-
-
-   create_context_modes =
-       (PFNGLXCREATECONTEXTMODES) glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
-   if ( create_context_modes != NULL ) {
-      *driver_modes = i810FillInModes( 16,
-                                      16, 0,
-                                      1);
+   if ( psp != NULL ) {
+      create_context_modes = (PFNGLXCREATECONTEXTMODES)
+         glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
+      if ( create_context_modes != NULL ) {
+        *driver_modes = i810FillInModes( 16,
+                                         16, 0,
+                                         1);
+      }
    }
 
    return (void *) psp;
index fa1c15154339db6a1f513f534a0d6391920a112d..6ef16c11b27525a41a08727798c35d47597cc3b1 100644 (file)
@@ -538,16 +538,16 @@ void * __driCreateNewScreen( Display *dpy, int scrn, __DRIscreen *psc,
                                  ddx_version, dri_version, drm_version,
                                  frame_buffer, pSAREA, fd,
                                  internal_api_version, &mach64API);
-
-
-   create_context_modes = 
-       (PFNGLXCREATECONTEXTMODES) glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
-   if ( create_context_modes != NULL ) {
-      ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv;
-      *driver_modes = mach64FillInModes( dri_priv->cpp * 8,
-                                        16,
-                                        0,
-                                        1);
+   if ( psp != NULL ) {
+      create_context_modes = (PFNGLXCREATECONTEXTMODES)
+         glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
+      if ( create_context_modes != NULL ) {
+        ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv;
+        *driver_modes = mach64FillInModes( dri_priv->cpp * 8,
+                                           16,
+                                           0,
+                                           1);
+      }
    }
 
    return (void *) psp;
index 3b65e7a40c35a1266799efb899da17da48072b8b..f0fe8d2c049e4905cae3cb1f2309684cc7aaa872 100644 (file)
@@ -967,16 +967,16 @@ void * __driCreateNewScreen( Display *dpy, int scrn, __DRIscreen *psc,
                                  ddx_version, dri_version, drm_version,
                                  frame_buffer, pSAREA, fd,
                                  internal_api_version, &mgaAPI);
-
-
-   create_context_modes = 
-       (PFNGLXCREATECONTEXTMODES) glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
-   if ( create_context_modes != NULL ) {
-      MGADRIPtr dri_priv = (MGADRIPtr) psp->pDevPriv;
-      *driver_modes = mgaFillInModes( dri_priv->cpp * 8,
-                                     (dri_priv->cpp == 2) ? 16 : 24,
-                                     (dri_priv->cpp == 2) ? 0  : 8,
-                                     (dri_priv->backOffset != dri_priv->depthOffset) );
+   if ( psp != NULL ) {
+      create_context_modes = (PFNGLXCREATECONTEXTMODES)
+         glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
+      if ( create_context_modes != NULL ) {
+        MGADRIPtr dri_priv = (MGADRIPtr) psp->pDevPriv;
+        *driver_modes = mgaFillInModes( dri_priv->cpp * 8,
+                                        (dri_priv->cpp == 2) ? 16 : 24,
+                                        (dri_priv->cpp == 2) ? 0  : 8,
+                                        (dri_priv->backOffset != dri_priv->depthOffset) );
+      }
    }
 
    return (void *) psp;
index 45683d8143b077a4bc7a619f27ee1bfda514306e..e356309ae10105eda9e5eae9ba35a0a1611dde25 100644 (file)
@@ -640,16 +640,16 @@ void * __driCreateNewScreen( Display *dpy, int scrn, __DRIscreen *psc,
                                  ddx_version, dri_version, drm_version,
                                  frame_buffer, pSAREA, fd,
                                  internal_api_version, &r200API);
-
-
-   create_context_modes = 
-       (PFNGLXCREATECONTEXTMODES) glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
-   if ( create_context_modes != NULL ) {
-      RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
-      *driver_modes = r200FillInModes( dri_priv->bpp,
-                                      (dri_priv->bpp == 16) ? 16 : 24,
-                                      (dri_priv->bpp == 16) ? 0  : 8,
-                                      (dri_priv->backOffset != dri_priv->depthOffset) );
+   if ( psp != NULL ) {
+      create_context_modes = (PFNGLXCREATECONTEXTMODES)
+         glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
+      if ( create_context_modes != NULL ) {
+        RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
+        *driver_modes = r200FillInModes( dri_priv->bpp,
+                                         (dri_priv->bpp == 16) ? 16 : 24,
+                                         (dri_priv->bpp == 16) ? 0  : 8,
+                                         (dri_priv->backOffset != dri_priv->depthOffset) );
+      }
    }
 
    return (void *) psp;
index c3ddb99486495116c7cdf13ee704596261dd4b08..8d26935e6befc973dc8b9cda946265f3f0d732c5 100644 (file)
@@ -602,16 +602,16 @@ void * __driCreateNewScreen( Display *dpy, int scrn, __DRIscreen *psc,
                                  ddx_version, dri_version, drm_version,
                                  frame_buffer, pSAREA, fd,
                                  internal_api_version, &radeonAPI);
-
-
-   create_context_modes =
-       (PFNGLXCREATECONTEXTMODES) glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
-   if ( create_context_modes != NULL ) {
-      RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
-      *driver_modes = radeonFillInModes( dri_priv->bpp,
-                                      (dri_priv->bpp == 16) ? 16 : 24,
-                                      (dri_priv->bpp == 16) ? 0  : 8,
-                                      (dri_priv->backOffset != dri_priv->depthOffset) );
+   if ( psp != NULL ) {
+      create_context_modes = (PFNGLXCREATECONTEXTMODES)
+         glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
+      if ( create_context_modes != NULL ) {
+        RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
+        *driver_modes = radeonFillInModes( dri_priv->bpp,
+                                           (dri_priv->bpp == 16) ? 16 : 24,
+                                           (dri_priv->bpp == 16) ? 0  : 8,
+                                           (dri_priv->backOffset != dri_priv->depthOffset) );
+      }
    }
 
    return (void *) psp;