зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1364513 - Ensure correct buffer initialization. r=mystor
--HG-- extra : rebase_source : af0024c26378f21da156e8f4e5da1b3bcc8c1ed8
This commit is contained in:
Родитель
3054ba2e79
Коммит
f78280f29a
|
@ -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();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче