diff options
author | Chad Versace <[email protected]> | 2014-11-18 21:11:24 -0800 |
---|---|---|
committer | Chad Versace <[email protected]> | 2014-12-22 15:47:07 -0600 |
commit | aebcf26d8219cee79da89313124c2147595a660c (patch) | |
tree | ed9e9d9b4bdad23ce032738501282f3ee8bae463 /src/mesa/drivers/dri/i965/intel_tex.c | |
parent | d11bc9fe8daf097741713cde6bdd79e1f0e0e8fc (diff) |
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 <[email protected]>
Signed-off-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/intel_tex.c')
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_tex.c | 7 |
1 files changed, 5 insertions, 2 deletions
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 |