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 218167 75c2f18b0020
parent 218166 aa636b6addb1
child 218168 6233fa4970a4
push id566
push userryanvm@gmail.com
push date2014-11-04 15:24 +0000
treeherdermozilla-release@75c2f18b0020 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, sledru
bugs1076910
milestone33.1
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
@@ -1211,16 +1211,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;
   }