trace: Defer the cast to after the check for enabled trace.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 25 Mar 2009 21:45:57 +0000 (21:45 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 25 Mar 2009 21:47:17 +0000 (21:47 +0000)
Prevents segfault when trace is disabled.

src/gallium/drivers/trace/tr_context.c

index c8949729047840a7144f34167c45dee05131fab5..b69ed2cb526701da1fcadb6156a822fca90ea7c6 100644 (file)
@@ -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;