Add artificial limits to the total memory allocated by the NULL backend.
Fuzzer tests were capable of allocating very large chunks of memory by
calling glBufferData with a null pointer. This sets a limit before the
NULL backend starts returning out of memory GL errors.
BUG=602737
Change-Id: Ic53ebcf999f951b96c1df82e4db57e949d03c908
Reviewed-on: https://chromium-review.googlesource.com/441184
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/null/DisplayNULL.cpp b/src/libANGLE/renderer/null/DisplayNULL.cpp
index 7596f1b..1caa7c8 100644
--- a/src/libANGLE/renderer/null/DisplayNULL.cpp
+++ b/src/libANGLE/renderer/null/DisplayNULL.cpp
@@ -30,11 +30,16 @@
egl::Error DisplayNULL::initialize(egl::Display *display)
{
mDevice = new DeviceNULL();
+
+ constexpr size_t kMaxTotalAllocationSize = 1 << 28; // 256MB
+ mAllocationTracker.reset(new AllocationTrackerNULL(kMaxTotalAllocationSize));
+
return egl::NoError();
}
void DisplayNULL::terminate()
{
+ mAllocationTracker.reset();
SafeDelete(mDevice);
}
@@ -168,7 +173,7 @@
ContextImpl *DisplayNULL::createContext(const gl::ContextState &state)
{
- return new ContextNULL(state);
+ return new ContextNULL(state, mAllocationTracker.get());
}
StreamProducerImpl *DisplayNULL::createStreamProducerD3DTextureNV12(