frontend/nine: Fix buffer tracking out of bounds

Fixes a crash in a ffxi trace, which draws out of bounds.
This was previously resulting in trying to fill a buffer
resource not big enough.

cc: mesa-stable
Fixes: 380c2bf ("st/nine: Optimize dynamic systemmem buffers")

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
Acked-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18021>
This commit is contained in:
Axel Davy
2022-08-11 22:04:57 +02:00
parent b74febffe6
commit e5124e83ba
2 changed files with 4 additions and 1 deletions
+1
View File
@@ -272,6 +272,7 @@ NineBuffer9_Lock( struct NineBuffer9 *This,
if (!(This->base.usage & D3DUSAGE_DYNAMIC) && This->base.pool == D3DPOOL_DEFAULT)
SizeToLock = This->size - OffsetToLock;
SizeToLock = MIN2(SizeToLock, This->size - OffsetToLock); /* Do not read or track out of the buffer */
u_box_1d(OffsetToLock, SizeToLock, &box);
if (This->base.pool != D3DPOOL_DEFAULT) {
+3 -1
View File
@@ -2983,7 +2983,9 @@ NineTrackSystemmemDynamic( struct NineBuffer9 *This, unsigned start, unsigned wi
{
struct pipe_box box;
u_box_1d(start, width, &box);
if (start >= This->size)
return; /* outside bounds, nothing to do */
u_box_1d(start, MIN2(width, This->size-start), &box);
u_box_union_1d(&This->managed.required_valid_region,
&This->managed.required_valid_region,
&box);