From aebcf26d8219cee79da89313124c2147595a660c Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Tue, 18 Nov 2014 21:11:24 -0800 Subject: i965: Fix intel_miptree_map() signature to be more 64-bit safe This patch should diminish the likelihood of pointer arithmetic overflow bugs, like the one fixed by b69c7c5dac. Change the type of parameter 'out_stride' from int to ptrdiff_t. The logic is that if you call intel_miptree_map() and use the value of 'out_stride', then you must be doing pointer arithmetic on 'out_ptr'. Using ptrdiff_t instead of int should make a little bit harder to hit overflow bugs. As a side-effect, some function-scope variables needed to be retyped to avoid compilation errors. Reviewed-by: Kenneth Graunke Signed-off-by: Chad Versace --- src/mesa/drivers/dri/i965/intel_copy_image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/drivers/dri/i965/intel_copy_image.c') diff --git a/src/mesa/drivers/dri/i965/intel_copy_image.c b/src/mesa/drivers/dri/i965/intel_copy_image.c index cb44474..f4c7eff 100644 --- a/src/mesa/drivers/dri/i965/intel_copy_image.c +++ b/src/mesa/drivers/dri/i965/intel_copy_image.c @@ -145,7 +145,7 @@ copy_image_with_memcpy(struct brw_context *brw, { bool same_slice; void *mapped, *src_mapped, *dst_mapped; - int src_stride, dst_stride, i, cpp; + ptrdiff_t src_stride, dst_stride, cpp; int map_x1, map_y1, map_x2, map_y2; GLuint src_bw, src_bh; @@ -197,7 +197,7 @@ copy_image_with_memcpy(struct brw_context *brw, src_width /= (int)src_bw; src_height /= (int)src_bh; - for (i = 0; i < src_height; ++i) { + for (int i = 0; i < src_height; ++i) { memcpy(dst_mapped, src_mapped, src_width * cpp); src_mapped += src_stride; dst_mapped += dst_stride; -- cgit v1.1