Commit 8470b533 by Jamie Madill Committed by Commit Bot

Set gl::Buffer to zero size when allocations fail.

It's undefined what happens if we run into OOM errors when allocating new resources. To guard against fuzzer issues we can set the buffer size internally to zero when an allocation fails. This should prevent GL APIs from reading from the buffer when the contents are internally inconsistent. Bug: chromium:1086532 Change-Id: I9ac4becf977bf0521208b2220caba788c21c93f1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2219137 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 3c00eee2
...@@ -87,7 +87,17 @@ angle::Result Buffer::bufferData(Context *context, ...@@ -87,7 +87,17 @@ angle::Result Buffer::bufferData(Context *context,
dataForImpl = scratchBuffer->data(); dataForImpl = scratchBuffer->data();
} }
ANGLE_TRY(mImpl->setData(context, target, dataForImpl, size, usage)); if (mImpl->setData(context, target, dataForImpl, size, usage) == angle::Result::Stop)
{
// If setData fails, the buffer contents are undefined. Set a zero size to indicate that.
mIndexRangeCache.clear();
mState.mSize = 0;
// Notify when storage changes.
onStateChange(angle::SubjectMessage::SubjectChanged);
return angle::Result::Stop;
}
mIndexRangeCache.clear(); mIndexRangeCache.clear();
mState.mUsage = usage; mState.mUsage = usage;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment