From 249cfaafdc45f4da83d4a3f7654a7c8274bb5539 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 26 Sep 2012 11:08:11 -0700 Subject: [PATCH 1/3] dri_util: Use calloc to allocate __DRIcontext 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 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 4276ad9..983bbea 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -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; -- 1.7.11.4