Bug 1261320 - Check DataSurface is vaild before using, r=milan
authorPeter Chang <pchang@mozilla.com>
Mon, 11 Apr 2016 17:45:09 +0800
changeset 316472 bd8532d1f56bfe0decb405c4bf607b1ae01c17fb
parent 316471 9c35ce0d49ada38c197f0ffaca026b3f66382c95
child 316473 f7bde8dff75c4f68846e5a5d863f46152fb1fceb
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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) {