From 0ea9c8037e69dbf26914553569e6c06a4e2c2cc5 Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Fri, 1 Jan 2016 14:00:48 -0500 Subject: [PATCH] Bug 1220450 - Clear length on cache OOM. r=kamidphish --- dom/canvas/WebGLContextBuffers.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dom/canvas/WebGLContextBuffers.cpp b/dom/canvas/WebGLContextBuffers.cpp index 7a221782e8d..1e6497c9b43 100644 --- a/dom/canvas/WebGLContextBuffers.cpp +++ b/dom/canvas/WebGLContextBuffers.cpp @@ -177,7 +177,9 @@ WebGLContext::BufferData(GLenum target, WebGLsizeiptr size, GLenum usage) } boundBuffer->SetByteLength(size); + if (!boundBuffer->ElementArrayCacheBufferData(nullptr, size)) { + boundBuffer->SetByteLength(0); return ErrorOutOfMemory("bufferData: out of memory"); } } @@ -227,9 +229,12 @@ WebGLContext::BufferDataT(GLenum target, } boundBuffer->SetByteLength(data.LengthAllowShared()); + // Warning: Possibly shared memory. See bug 1225033. - if (!boundBuffer->ElementArrayCacheBufferData(data.DataAllowShared(), data.LengthAllowShared())) + if (!boundBuffer->ElementArrayCacheBufferData(data.DataAllowShared(), data.LengthAllowShared())) { + boundBuffer->SetByteLength(0); return ErrorOutOfMemory("bufferData: out of memory"); + } } void