AGS: Common: fail early in negative index

from upstream 4d9f1788059b2fdadd3e957a5a260a918458595d
This commit is contained in:
Walter Agazzi 2023-02-26 18:56:23 +01:00 committed by Thierry Crozat
parent 5ad85c6b42
commit a32892578a

View File

@ -108,7 +108,7 @@ Rect GUIButton::CalcGraphicRect(bool clipped) {
if (IsClippingImage())
return rc;
// Main button graphic
if (_GP(spriteset)[CurrentImage] != nullptr)
if (CurrentImage >= 0 && _GP(spriteset)[CurrentImage] != nullptr)
rc = SumRects(rc, RectWH(0, 0, get_adjusted_spritewidth(CurrentImage), get_adjusted_spriteheight(CurrentImage)));
// Optionally merge with the inventory pic
if (_placeholder != kButtonPlace_None && _G(gui_inv_pic) >= 0) {