brw_bo_alloc may round up our allocation size to the next bucket size. In this case, we would malloc a shadow buffer that was the original intended size, but use bo->size (the larger size) for all of our checks.
This could cause us to run off the end of the shadow buffer. Reported-by: James Xiong <james.xi...@intel.com> --- src/mesa/drivers/dri/i965/intel_batchbuffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index 55889be7327..1c5574cbfb0 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -360,8 +360,11 @@ grow_buffer(struct brw_context *brw, /* We can't safely use realloc, as it may move the existing buffer, * breaking existing pointers the caller may still be using. Just * malloc a new copy and memcpy it like the normal BO path. + * + * Use bo->size rather than new_size because the bufmgr may have + * rounded up the size, and we want the shadow size to match. */ - grow->map = malloc(new_size); + grow->map = malloc(bo->size); } else { grow->map = brw_bo_map(brw, new_bo, MAP_READ | MAP_WRITE); } -- 2.16.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev