1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Prevent integer overflow in BitmapData::getLinePointer() and BitmapData::getPixelPointer()

This commit is contained in:
ed 2019-08-28 10:41:04 +01:00
parent 9561732818
commit 383d69c421

View file

@ -326,13 +326,13 @@ public:
The coordinate you provide here isn't checked, so it's the caller's responsibility to make
sure it's not out-of-range.
*/
inline uint8* getLinePointer (int y) const noexcept { return data + y * lineStride; }
inline uint8* getLinePointer (int y) const noexcept { return data + (size_t) y * (size_t) lineStride; }
/** Returns a pointer to a pixel in the image.
The coordinates you give here are not checked, so it's the caller's responsibility to make sure they're
not out-of-range.
*/
inline uint8* getPixelPointer (int x, int y) const noexcept { return data + y * lineStride + x * pixelStride; }
inline uint8* getPixelPointer (int x, int y) const noexcept { return data + (size_t) y * (size_t) lineStride + (size_t) x * (size_t) pixelStride; }
/** Returns the colour of a given pixel.
For performance reasons, this won't do any bounds-checking on the coordinates, so it's the caller's