mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-26 01:08:39 +09:00
Check for too large allocation size in BasicPlanarYCbCrImage::CopyData (DiD)
This commit is contained in:
parent
d49f17dcbc
commit
4cdd40dc7f
1 changed files with 8 additions and 1 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include "gfxASurface.h" // for gfxASurface, etc
|
||||
#include "gfxPlatform.h" // for gfxPlatform, gfxImageFormat
|
||||
#include "gfxUtils.h" // for gfxUtils
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/mozalloc.h" // for operator delete[], etc
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
|
@ -111,7 +112,13 @@ BasicPlanarYCbCrImage::CopyData(const Data& aData)
|
|||
|
||||
gfxImageFormat iFormat = gfx::SurfaceFormatToImageFormat(format);
|
||||
mStride = gfxASurface::FormatStrideForWidth(iFormat, size.width);
|
||||
mDecodedBuffer = AllocateBuffer(size.height * mStride);
|
||||
mozilla::CheckedInt32 requiredBytes =
|
||||
mozilla::CheckedInt32(size.height) * mozilla::CheckedInt32(mStride);
|
||||
if (!requiredBytes.isValid()) {
|
||||
// invalid size
|
||||
return false;
|
||||
}
|
||||
mDecodedBuffer = AllocateBuffer(requiredBytes.value());
|
||||
if (!mDecodedBuffer) {
|
||||
// out of memory
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue