Bug 1268155 - GetAsSourceSurface might return nullptr, let's handle it. r=jgilbert
authorMorris Tseng <mtseng@mozilla.com>
Thu, 12 May 2016 14:08:24 +0800
changeset 297088 218969cdfaf0a78d9d5d0490b38532782ea902fe
parent 297087 f940ea93119c2bcaf1010e58b0bec75c99a10c7b
child 297089 eb8f153723e05479cd76cc2b6486eb2a32e42663
push id76594
push usermtseng@mozilla.com
push dateThu, 12 May 2016 06:09:40 +0000
treeherdermozilla-inbound@218969cdfaf0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1268155
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1268155 - GetAsSourceSurface might return nullptr, let's handle it. r=jgilbert 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