Bug 1076910 - Add some error checks to gfxUtils::EncodeSourceSurface. r=Bas
authorJonathan Watt <jwatt@jwatt.org>
Fri, 31 Oct 2014 11:16:45 +0000
changeset 213390 0e1a08d24467827e2082ed9fa4b927b3044e7bac
parent 213389 920fc43b861f5335d32e830b96e4db793399bd56
child 213391 b062dcf0c52b485bae473a4c4b00961d2c0cdba8
push id27748
push userryanvm@gmail.com
push dateFri, 31 Oct 2014 20:14:33 +0000
treeherdermozilla-central@12ac66e2c016 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1076910
milestone36.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 1076910 - Add some error checks to gfxUtils::EncodeSourceSurface. r=Bas
gfx/thebes/gfxUtils.cpp
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -1179,16 +1179,18 @@ gfxUtils::EncodeSourceSurface(SourceSurf
     if (imgSize == bufSize) {
       // need a bigger buffer, just double
       bufSize *= 2;
       if (!imgData.resizeUninitialized(bufSize)) {
         return NS_ERROR_OUT_OF_MEMORY;
       }
     }
   }
+  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_TRUE(!imgData.empty(), NS_ERROR_FAILURE);
 
   if (aBinaryOrData == eBinaryEncode) {
     if (aFile) {
       fwrite(imgData.begin(), 1, imgSize, aFile);
     }
     return NS_OK;
   }