Bug 1573048 - Add size check to WebGLContext::BufferData() r=jgilbert a=RyanVM
authorsotaro <sotaro.ikeda.g@gmail.com>
Thu, 26 Sep 2019 04:18:30 +0000
changeset 523761 b8256788d3ae67588372f0990a3fd2c3ed826fcb
parent 523760 3c725f75c8bab7fe442b3bb5968e8f189a17e069
child 523762 9446b1758ef2da6609cdae60d8a272f909ce2c17
push id431
push userryanvm@gmail.com
push dateTue, 01 Oct 2019 19:25:39 +0000
treeherdermozilla-esr68@9446b1758ef2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert, RyanVM
bugs1573048
milestone68.2.0
Bug 1573048 - Add size check to WebGLContext::BufferData() r=jgilbert a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D44619
dom/canvas/WebGLContextBuffers.cpp
--- a/dom/canvas/WebGLContextBuffers.cpp
+++ b/dom/canvas/WebGLContextBuffers.cpp
@@ -302,16 +302,23 @@ void WebGLContext::BufferData(GLenum tar
   if (!ValidateNonNegative("size", size)) return;
 
   ////
 
   const auto checkedSize = CheckedInt<size_t>(size);
   if (!checkedSize.isValid())
     return ErrorOutOfMemory("size too large for platform.");
 
+#if defined(XP_MACOSX)
+  // bug 1573048
+  if (gl->WorkAroundDriverBugs() && size > 1200000000) {
+    return ErrorOutOfMemory("Allocations larger than 1200000000 fail on macOS.");
+  }
+#endif
+
   const UniqueBuffer zeroBuffer(calloc(checkedSize.value(), 1u));
   if (!zeroBuffer) return ErrorOutOfMemory("Failed to allocate zeros.");
 
   BufferDataImpl(target, uint64_t{checkedSize.value()},
                  (const uint8_t*)zeroBuffer.get(), usage);
 }
 
 void WebGLContext::BufferData(GLenum target,