summaryrefslogtreecommitdiff
path: root/src/mesa/swrast/s_stencil.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2005-09-16 21:15:27 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2005-09-16 21:15:27 +0000
commit67074332728acba86da7630353673b458713bb8a (patch)
treeee17b8b91b16ef04df684157d2b25983373268e7 /src/mesa/swrast/s_stencil.c
parent82e314252f0b706c3ae1c748e9d64d8fa58812db (diff)
Fix potential segfault when trying to read pixels outside renderbuffer bounds.
Use _swrast_get_values() which does clipping.
Diffstat (limited to 'src/mesa/swrast/s_stencil.c')
-rw-r--r--src/mesa/swrast/s_stencil.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c
index 3e1b28740a..d8e49cbe41 100644
--- a/src/mesa/swrast/s_stencil.c
+++ b/src/mesa/swrast/s_stencil.c
@@ -32,6 +32,7 @@
#include "s_context.h"
#include "s_depth.h"
#include "s_stencil.h"
+#include "s_span.h"
@@ -460,7 +461,7 @@ stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span, GLuint face)
GLuint i;
/* save the current mask bits */
- MEMCPY(oldmask, mask, n * sizeof(GLubyte));
+ _mesa_memcpy(oldmask, mask, n * sizeof(GLubyte));
/* apply the depth test */
_swrast_depth_test_span(ctx, span);
@@ -913,9 +914,10 @@ stencil_and_ztest_pixels( GLcontext *ctx, struct sw_span *span, GLuint face )
GLstencil stencil[MAX_WIDTH];
GLubyte origMask[MAX_WIDTH];
- rb->GetValues(ctx, rb, n, x, y, stencil);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ _swrast_get_values(ctx, rb, n, x, y, stencil, sizeof(GLubyte));
- MEMCPY(origMask, mask, n * sizeof(GLubyte));
+ _mesa_memcpy(origMask, mask, n * sizeof(GLubyte));
(void) do_stencil_test(ctx, face, n, stencil, mask);
@@ -969,7 +971,7 @@ stencil_and_ztest_pixels( GLcontext *ctx, struct sw_span *span, GLuint face )
GLubyte passmask[MAX_WIDTH], failmask[MAX_WIDTH], oldmask[MAX_WIDTH];
GLuint i;
- MEMCPY(oldmask, mask, n * sizeof(GLubyte));
+ _mesa_memcpy(oldmask, mask, n * sizeof(GLubyte));
_swrast_depth_test_span(ctx, span);