Bug 1268155 - GetAsSourceSurface might return nullptr, let's handle it. r=jgilbert a=ritu
authorMorris Tseng <mtseng@mozilla.com>
Thu, 12 May 2016 14:08:24 +0800
changeset 324430 bf9ab1205db9b4c5f520f058dd3c37d1dd2b7cd6
parent 324429 0484d5adb31140d4d4d4a1efa5c2bfdd06d14414
child 324431 f0f690f287d8ee65c660ae30fcbaec710af6c58b
push id6009
push userkwierso@gmail.com
push dateThu, 19 May 2016 00:32:39 +0000
treeherdermozilla-beta@0723a0212f5e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert, ritu
bugs1268155
milestone47.0
Bug 1268155 - GetAsSourceSurface might return nullptr, let's handle it. r=jgilbert a=ritu MozReview-Commit-ID: 6uH9esA2PqC
dom/canvas/TexUnpackBlob.cpp
--- a/dom/canvas/TexUnpackBlob.cpp
+++ b/dom/canvas/TexUnpackBlob.cpp
@@ -306,17 +306,23 @@ TexUnpackImage::TexOrSubImage(bool isSub
                                                       dstOrigin))
         {
             break;
         }
 
         return; // Blitting was successful, so we're done!
     } while (false);
 
-    TexUnpackSurface surfBlob(mImage->GetAsSourceSurface(), mIsAlphaPremult);
+    RefPtr<SourceSurface> surface = mImage->GetAsSourceSurface();
+    if (!surface) {
+        *out_glError = LOCAL_GL_OUT_OF_MEMORY;
+        return;
+    }
+
+    TexUnpackSurface surfBlob(surface, mIsAlphaPremult);
 
     surfBlob.TexOrSubImage(isSubImage, needsRespec, funcName, tex, target, level, dui,
                            xOffset, yOffset, zOffset, out_glError);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////
 // TexUnpackSurface