Bug 1364513 - Ensure correct buffer initialization. r=mystor

--HG--
extra : rebase_source : af0024c26378f21da156e8f4e5da1b3bcc8c1ed8
This commit is contained in:
Olli Pettay 2017-05-25 09:39:17 -04:00
Родитель 3054ba2e79
Коммит f78280f29a
1 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/ImageBitmap.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/dom/ImageBitmapBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/StructuredCloneTags.h"
@ -175,10 +175,14 @@ CropAndCopyDataSourceSurface(DataSourceSurface* aSurface, const IntRect& aCropRe
+ surfPortion.x * bytesPerPixel;
uint8_t* dstBufferPtr = dstMap.GetData() + dest.y * dstMap.GetStride()
+ dest.x * bytesPerPixel;
const uint32_t copiedBytesPerRaw = surfPortion.width * bytesPerPixel;
CheckedInt<uint32_t> copiedBytesPerRaw =
CheckedInt<uint32_t>(surfPortion.width) * bytesPerPixel;
if (!copiedBytesPerRaw.isValid()) {
return nullptr;
}
for (int i = 0; i < surfPortion.height; ++i) {
memcpy(dstBufferPtr, srcBufferPtr, copiedBytesPerRaw);
memcpy(dstBufferPtr, srcBufferPtr, copiedBytesPerRaw.value());
srcBufferPtr += srcMap.GetStride();
dstBufferPtr += dstMap.GetStride();
}