summaryrefslogtreecommitdiffstats
path: root/image/encoders/jpeg/nsJPEGEncoder.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-07-10 18:46:10 +0000
committerMoonchild <moonchild@palemoon.org>2020-07-10 18:46:10 +0000
commitf1b51be787c11090c8d9b2ec73255df7a67c7eb7 (patch)
tree9c6d35ce6f19e0fef3c47c7e2c152394854cf217 /image/encoders/jpeg/nsJPEGEncoder.cpp
parent2deaddfca28508ac1a634eb6088a1da8e571ec6e (diff)
parent82faff19e1761797b7a75f9221f0709c5a38bfe6 (diff)
downloadUXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar
UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar.gz
UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar.lz
UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar.xz
UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.zip
Merge branch 'redwood' into releaseRELBASE_20200711
Diffstat (limited to 'image/encoders/jpeg/nsJPEGEncoder.cpp')
-rw-r--r--image/encoders/jpeg/nsJPEGEncoder.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/image/encoders/jpeg/nsJPEGEncoder.cpp b/image/encoders/jpeg/nsJPEGEncoder.cpp
index 04cfef07b..e5835c295 100644
--- a/image/encoders/jpeg/nsJPEGEncoder.cpp
+++ b/image/encoders/jpeg/nsJPEGEncoder.cpp
@@ -8,6 +8,7 @@
#include "nsString.h"
#include "nsStreamUtils.h"
#include "gfxColor.h"
+#include "mozilla/CheckedInt.h"
#include <setjmp.h>
#include "jerror.h"
@@ -430,10 +431,14 @@ nsJPEGEncoder::emptyOutputBuffer(jpeg_compress_struct* cinfo)
that->mImageBufferUsed = that->mImageBufferSize;
// expand buffer, just double size each time
- that->mImageBufferSize *= 2;
+ uint8_t* newBuf = nullptr;
+ CheckedInt<uint32_t> bufSize =
+ CheckedInt<uint32_t>(that->mImageBufferSize) * 2;
+ if (bufSize.isValid()) {
+ that->mImageBufferSize = bufSize.value();
+ newBuf = (uint8_t*)realloc(that->mImageBuffer, that->mImageBufferSize);
+ }
- uint8_t* newBuf = (uint8_t*)realloc(that->mImageBuffer,
- that->mImageBufferSize);
if (!newBuf) {
// can't resize, just zero (this will keep us from writing more)
free(that->mImageBuffer);