mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Fix out of bounds read for sf::Image::copy()
with bad sourceRect
This commit is contained in:
parent
8b3723a52b
commit
91c4a451ef
@ -177,6 +177,11 @@ void Image::copy(const Image& source, const Vector2u& dest, const IntRect& sourc
|
||||
if ((source.m_size.x == 0) || (source.m_size.y == 0) || (m_size.x == 0) || (m_size.y == 0))
|
||||
return;
|
||||
|
||||
// Make sure the sourceRect left & top and the {left, top} + {width, height} within bounds
|
||||
if (static_cast<unsigned int>(sourceRect.left) >= source.m_size.x || static_cast<unsigned int>(sourceRect.left + sourceRect.width) > source.m_size.x ||
|
||||
static_cast<unsigned int>(sourceRect.top) >= source.m_size.y || static_cast<unsigned int>(sourceRect.top + sourceRect.height) > source.m_size.y)
|
||||
return;
|
||||
|
||||
// Adjust the source rectangle
|
||||
IntRect srcRect = sourceRect;
|
||||
if (srcRect.width == 0 || (srcRect.height == 0))
|
||||
|
Loading…
Reference in New Issue
Block a user