Bug 1261320 - Check DataSurface is vaild before using, r=milan draft
authorPeter Chang <pchang@mozilla.com>
Mon, 11 Apr 2016 17:45:09 +0800
changeset 349608 9b32210dbee3a44824d815a89e098c79c9de7915
parent 349344 3d6ba7680c830bc415864636987905f62c91ad18
child 518156 e99d50590541785dd37c6f3cdd4070e99ebab0a3
push id15147
push userbmo:howareyou322@gmail.com
push dateTue, 12 Apr 2016 01:34:47 +0000
reviewersmilan
bugs1261320
milestone48.0a1
Bug 1261320 - Check DataSurface is vaild before using, r=milan MozReview-Commit-ID: 1uhNttyNAiq
dom/canvas/TexUnpackBlob.cpp
--- a/dom/canvas/TexUnpackBlob.cpp
+++ b/dom/canvas/TexUnpackBlob.cpp
@@ -751,17 +751,23 @@ TexUnpackSurface::TexOrSubImage(bool isS
 
     WebGLContext* webgl = tex->mContext;
 
     // MakeCurrent is a big mess in here, because mapping (and presumably unmapping) on
     // OSX can lose our MakeCurrent. Therefore it's easiest to MakeCurrent just before we
     // call into GL, instead of trying to keep MakeCurrent-ed.
 
     RefPtr<gfx::DataSourceSurface> dataSurf = mSurf->GetDataSurface();
-    MOZ_ASSERT(dataSurf);
+
+    if (!dataSurf) {
+        // Since GetDataSurface didn't return error code, assume system
+        // is out of memory
+        *out_glError = LOCAL_GL_OUT_OF_MEMORY;
+        return;
+    }
 
     GLenum error;
     if (UploadDataSurface(isSubImage, webgl, target, level, dui, xOffset, yOffset,
                           zOffset, mWidth, mHeight, dataSurf, mIsAlphaPremult, &error))
     {
         return;
     }
     if (error == LOCAL_GL_OUT_OF_MEMORY) {