diff options
author | Pale Moon <git-repo@palemoon.org> | 2017-04-21 16:00:07 +0200 |
---|---|---|
committer | Pale Moon <git-repo@palemoon.org> | 2017-04-21 16:00:07 +0200 |
commit | 2198f3c14033ac934a44cd8f104eb7c3072c9a6d (patch) | |
tree | dfba4f7ddee69b871850df67bb3a017161e41ee0 /gfx | |
parent | 9ab46145b36a50096e7fcc7cf5043ccf8f3fa20d (diff) | |
download | palemoon-gre-2198f3c14033ac934a44cd8f104eb7c3072c9a6d.tar.gz |
Add some bounds checks.
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/layers/ImageContainer.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gfx/layers/ImageContainer.cpp b/gfx/layers/ImageContainer.cpp index 3b4e9b562..1f19a6bec 100644 --- a/gfx/layers/ImageContainer.cpp +++ b/gfx/layers/ImageContainer.cpp @@ -25,6 +25,7 @@ #endif #include "gfx2DGlue.h" #include "mozilla/gfx/2D.h" +#include "mozilla/CheckedInt.h" #ifdef XP_MACOSX #include "mozilla/gfx/QuartzSupport.h" @@ -391,8 +392,15 @@ PlanarYCbCrImage::CopyData(const Data& aData) mData = aData; // update buffer size - size_t size = mData.mCbCrStride * mData.mCbCrSize.height * 2 + - mData.mYStride * mData.mYSize.height; + // Use uint32_t throughout to match AllocateBuffer's param and mBufferSize + const auto checkedSize = + CheckedInt<uint32_t>(mData.mCbCrStride) * mData.mCbCrSize.height * 2 + + CheckedInt<uint32_t>(mData.mYStride) * mData.mYSize.height; + + if (!checkedSize.isValid()) + return; + + const auto size = checkedSize.value(); // get new buffer mBuffer = AllocateBuffer(size); |