swrast: Fix signed/unsigned problems with negative strides.
authorMathias Fröhlich <Mathias.Froehlich@web.de>
Thu, 1 Dec 2011 19:48:10 +0000 (20:48 +0100)
committerMathias Fröhlich <Mathias.Froehlich@web.de>
Thu, 1 Dec 2011 20:44:57 +0000 (21:44 +0100)
In swrast_map_renderbuffer negative strides lead to
render buffer map pointers that are off by 2^32.
Make sure that intermediate negative values are not
converted to an unsigned.

Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/drivers/dri/swrast/swrast.c

index bc115e8cf1a15177a5fcc4d4e78b4bd9ff7a6719..629760441ad58fc2fb46d158b91d2ddc6c75d919 100644 (file)
@@ -419,8 +419,8 @@ swrast_map_renderbuffer(struct gl_context *ctx,
       stride = -stride;
    }
 
-   map += y * stride;
-   map += x * cpp;
+   map += (GLsizei)y * stride;
+   map += (GLsizei)x * cpp;
 
    *out_map = map;
    *out_stride = stride;