dri_util: Use calloc to allocate __DRIcontext
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 26 Sep 2012 18:08:11 +0000 (11:08 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 28 Sep 2012 22:05:24 +0000 (15:05 -0700)
The __DRIcontext contains some pointers, and some drivers check for them to be
NULL in some failure paths.  Instead of sprinkling NULL assignments across the
various drivers, just zero out the whole thing.

NOTE: This is a candidate for the 9.0 branch.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-and-tested-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Lu Hua <huax.lu@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=53618
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54301

src/mesa/drivers/dri/common/dri_util.c

index 4276ad981f91f6a5ab896abaa0f7499e4731d50d..983bbea49dad8131c81acb86aa7b17254eefa2ca 100644 (file)
@@ -272,7 +272,7 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api,
        return NULL;
     }
 
-    context = malloc(sizeof *context);
+    context = calloc(1, sizeof *context);
     if (!context) {
        *error = __DRI_CTX_ERROR_NO_MEMORY;
        return NULL;