Bounds check on bitmap add.

This commit is contained in:
riperiperi 2022-05-25 19:20:20 +01:00
parent 1fac9dc29b
commit d4b9a6378f

View file

@ -24,6 +24,12 @@
public void Add(int cbIndex, int offset, int size) public void Add(int cbIndex, int offset, int size)
{ {
// Some usages can be out of bounds (vertex buffer on amd), so bound if necessary.
if (offset + size > _size)
{
size = _size - offset;
}
int cbBase = cbIndex * _bitsPerCb; int cbBase = cbIndex * _bitsPerCb;
int start = cbBase + offset / _granularity; int start = cbBase + offset / _granularity;
int end = cbBase + (offset + size - 1) / _granularity; int end = cbBase + (offset + size - 1) / _granularity;