Bug 1101195 - Update imgData vector length after reading into it. r=jwatt
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -1194,16 +1194,19 @@ gfxUtils::EncodeSourceSurface(SourceSurf
if (!imgData.initCapacity(bufSize)) {
return NS_ERROR_OUT_OF_MEMORY;
}
uint32_t numReadThisTime = 0;
while ((rv = imgStream->Read(imgData.begin() + imgSize,
bufSize - imgSize,
&numReadThisTime)) == NS_OK && numReadThisTime > 0)
{
+ // Update the length of the vector without overwriting the new data.
+ imgData.growByUninitialized(numReadThisTime);
+
imgSize += numReadThisTime;
if (imgSize == bufSize) {
// need a bigger buffer, just double
bufSize *= 2;
if (!imgData.resizeUninitialized(bufSize)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}