Skip to content

Commit 39da8ca

Browse files
committed
avoid integer overflow in putImageData
1 parent 304bc9c commit 39da8ca

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/CanvasRenderingContext2d.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ Context2d::PutImageData(const Napi::CallbackInfo& info) {
842842
int Bpp = dstStride / canvas()->getWidth();
843843
int srcStride = Bpp * imageData->width();
844844

845-
int sx = 0
845+
int64_t sx = 0
846846
, sy = 0
847847
, sw = 0
848848
, sh = 0

src/ImageData.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ class ImageData : public Napi::ObjectWrap<ImageData> {
1212
Napi::Value GetWidth(const Napi::CallbackInfo& info);
1313
Napi::Value GetHeight(const Napi::CallbackInfo& info);
1414

15-
inline int width() { return _width; }
16-
inline int height() { return _height; }
15+
inline uint32_t width() { return _width; }
16+
inline uint32_t height() { return _height; }
1717
inline uint8_t *data() { return _data; }
1818

1919
Napi::Env env;
2020

2121
private:
22-
int _width;
23-
int _height;
22+
uint32_t _width;
23+
uint32_t _height;
2424
uint8_t *_data;
2525

2626
};

0 commit comments

Comments
 (0)