draw: Avoid NULL pointer dereference when binding NULL fragment shaders.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 2 Feb 2012 13:19:56 +0000 (13:19 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 2 Feb 2012 14:45:30 +0000 (14:45 +0000)
Now that the draw module avoids flushing, it may flush precisely when
binding a NULL shader, so care must be taken when restoring the original
fragment shader.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/draw/draw_pipe_aaline.c
src/gallium/auxiliary/draw/draw_pipe_aapoint.c
src/gallium/auxiliary/draw/draw_pipe_pstipple.c

index 0b368da6747187640f008c2434131c0e1d8168b4..ea0a4fb3f2508122db3df95216619b9c2266f55d 100644 (file)
@@ -738,7 +738,7 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
 
    /* restore original frag shader, texture, sampler state */
    draw->suspend_flushing = TRUE;
-   aaline->driver_bind_fs_state(pipe, aaline->fs->driver_fs);
+   aaline->driver_bind_fs_state(pipe, aaline->fs ? aaline->fs->driver_fs : NULL);
    aaline->driver_bind_sampler_states(pipe, aaline->num_samplers,
                                       aaline->state.sampler);
    aaline->driver_set_sampler_views(pipe,
index 248f26b91fda93eb6cd6d9388ff656d0af1cc36d..a900dd3ab5411587ecf5a1ea429e8f8a7b368d61 100644 (file)
@@ -744,7 +744,7 @@ aapoint_flush(struct draw_stage *stage, unsigned flags)
 
    /* restore original frag shader */
    draw->suspend_flushing = TRUE;
-   aapoint->driver_bind_fs_state(pipe, aapoint->fs->driver_fs);
+   aapoint->driver_bind_fs_state(pipe, aapoint->fs ? aapoint->fs->driver_fs : NULL);
 
    /* restore original rasterizer state */
    if (draw->rast_handle) {
index 0401a45507b04d0c3875588b9dd82724c782a6fd..62c54b35bc75756e97a5262e8149eb54af47256e 100644 (file)
@@ -565,7 +565,7 @@ pstip_flush(struct draw_stage *stage, unsigned flags)
 
    /* restore original frag shader, texture, sampler state */
    draw->suspend_flushing = TRUE;
-   pstip->driver_bind_fs_state(pipe, pstip->fs->driver_fs);
+   pstip->driver_bind_fs_state(pipe, pstip->fs ? pstip->fs->driver_fs : NULL);
    pstip->driver_bind_sampler_states(pipe, pstip->num_samplers,
                                      pstip->state.samplers);
    pstip->driver_set_sampler_views(pipe,