OSDN Git Service

swrast: new assertions in _swrast_pixel_address()
authorBrian Paul <brianp@vmware.com>
Mon, 16 Jan 2012 17:54:53 +0000 (10:54 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Sat, 28 Jan 2012 01:43:21 +0000 (17:43 -0800)
(cherry picked from commit 33257803d9083643ea9709c127933d5a2c4f1960)

src/mesa/swrast/s_context.h

index 3391600..36ab86a 100644 (file)
@@ -430,6 +430,14 @@ _swrast_pixel_address(struct gl_renderbuffer *rb, GLint x, GLint y)
 {
    const GLint bpp = _mesa_get_format_bytes(rb->Format);
    const GLint rowStride = rb->RowStride * bpp;
+   assert(x >= 0);
+   assert(y >= 0);
+   /* NOTE: using <= only because of s_tritemp.h which gets a pixel
+    * address but doesn't necessarily access it.
+    */
+   assert(x <= (GLint) rb->Width);
+   assert(y <= (GLint) rb->Height);
+   assert(rb->Data);
    return (GLubyte *) rb->Data + y * rowStride + x * bpp;
 }