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_tex.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/mesa/drivers/dri/i965/intel_tex.c') diff --git a/src/mesa/drivers/dri/i965/intel_tex.c b/src/mesa/drivers/dri/i965/intel_tex.c index 549d9b833c9..3be72d5faa1 100644 --- a/src/mesa/drivers/dri/i965/intel_tex.c +++ b/src/mesa/drivers/dri/i965/intel_tex.c @@ -205,11 +205,12 @@ intel_map_texture_image(struct gl_context *ctx, GLuint x, GLuint y, GLuint w, GLuint h, GLbitfield mode, GLubyte **map, - GLint *stride) + GLint *out_stride) { struct brw_context *brw = brw_context(ctx); struct intel_texture_image *intel_image = intel_texture_image(tex_image); struct intel_mipmap_tree *mt = intel_image->mt; + ptrdiff_t stride; /* Our texture data is always stored in a miptree. */ assert(mt); @@ -228,7 +229,9 @@ intel_map_texture_image(struct gl_context *ctx, tex_image->Level + tex_image->TexObject->MinLevel, slice + tex_image->TexObject->MinLayer, x, y, w, h, mode, - (void **)map, stride); + (void **)map, &stride); + + *out_stride = stride; } static void -- cgit v1.2.3