Bug 1076910 - Add some error checks to gfxUtils::EncodeSourceSurface. r=Bas, a=sledru
authorJonathan Watt <jwatt@jwatt.org>
Fri, 31 Oct 2014 11:16:45 +0000
changeset 225894 3c329a6fd0cb
parent 225893 8977f5061773
child 225895 631a73cdbc91
push id4059
push userryanvm@gmail.com
push date2014-10-31 21:13 +0000
treeherdermozilla-beta@631a73cdbc91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, sledru
bugs1076910
milestone34.0
Bug 1076910 - Add some error checks to gfxUtils::EncodeSourceSurface. r=Bas, a=sledru
gfx/thebes/gfxUtils.cpp
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -1204,16 +1204,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;
   }