From: José Fonseca Date: Wed, 25 Mar 2009 21:45:57 +0000 (+0000) Subject: trace: Defer the cast to after the check for enabled trace. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=57ea34214c114539a92eafafebf7e7fcfa9fc286;p=mesa.git trace: Defer the cast to after the check for enabled trace. Prevents segfault when trace is disabled. --- diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index c8949729047..b69ed2cb526 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1037,9 +1037,9 @@ struct pipe_context * trace_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) { - struct trace_screen *tr_scr = trace_screen(_screen); + struct trace_screen *tr_scr; struct trace_context *tr_ctx; - struct pipe_screen *screen = tr_scr->screen; + struct pipe_screen *screen; if(!pipe) goto error1; @@ -1047,6 +1047,9 @@ trace_context_create(struct pipe_screen *_screen, if(!trace_dump_enabled()) goto error1; + tr_scr = trace_screen(_screen); + screen = tr_scr->screen; + tr_ctx = CALLOC_STRUCT(trace_context); if(!tr_ctx) goto error1;