mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 03:08:05 +02:00
i965: Use safer pointer arithmetic in intel_texsubimage_tiled_memcpy()
This patch reduces the likelihood of pointer arithmetic overflow bugs in intel_texsubimage_tiled_memcpy() , like the one fixed byb69c7c5dac. I haven't yet encountered any overflow bugs in the wild along this patch's codepath. But I recently solved, in commitb69c7c5dac, an overflow bug in a line of code that looks very similar to pointer arithmetic in this function. This patch conceptually applies the same fix as inb69c7c5dac. Instead of retyping the variables, though, this patch adds some casts. (I tried to retype the variables as ptrdiff_t, but it quickly got very messy. The casts are cleaner). Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Chad Versace <chad.versace@linux.intel.com> (cherry picked from commit225a09790d)
This commit is contained in:
parent
87017f210d
commit
71cd8f1388
1 changed files with 4 additions and 3 deletions
|
|
@ -494,8 +494,8 @@ linear_to_tiled(uint32_t xt1, uint32_t xt2,
|
|||
/* Translate by (xt,yt) for single-tile copier. */
|
||||
tile_copy(x0-xt, x1-xt, x2-xt, x3-xt,
|
||||
y0-yt, y1-yt,
|
||||
dst + xt * th + yt * dst_pitch,
|
||||
src + xt + yt * src_pitch,
|
||||
dst + (ptrdiff_t) xt * th + (ptrdiff_t) yt * dst_pitch,
|
||||
src + (ptrdiff_t) xt + (ptrdiff_t) yt * src_pitch,
|
||||
src_pitch,
|
||||
swizzle_bit,
|
||||
mem_copy);
|
||||
|
|
@ -660,7 +660,8 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
|
|||
linear_to_tiled(
|
||||
xoffset * cpp, (xoffset + width) * cpp,
|
||||
yoffset, yoffset + height,
|
||||
bo->virtual, pixels - yoffset * src_pitch - xoffset * cpp,
|
||||
bo->virtual,
|
||||
pixels - (ptrdiff_t) yoffset * src_pitch - (ptrdiff_t) xoffset * cpp,
|
||||
image->mt->pitch, src_pitch,
|
||||
brw->has_swizzling,
|
||||
image->mt->tiling,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue