[Mesa-dev] [PATCH] draw: Avoid NULL pointer dereference when binding NULL fragment shaders.
jfonseca at vmware.com
jfonseca at vmware.com
Thu Feb 2 05:20:12 PST 2012
From: José Fonseca <jfonseca at vmware.com>
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.
---
src/gallium/auxiliary/draw/draw_pipe_aaline.c | 2 +-
src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 2 +-
src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 0b368da..ea0a4fb 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -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,
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index 248f26b..a900dd3 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
@@ -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) {
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index 0401a45..62c54b3 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -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,
--
1.7.7.3
More information about the mesa-dev
mailing list