* BugFix: Correct an ASAN reported memory access error when calling updateHeight on GuiGameListMenuCtrl when an invalid profile is initially set.

This commit is contained in:
Robert MacGregor 2021-11-02 08:16:54 -04:00
parent a0e0e1f220
commit 724e4f423c

View file

@ -543,7 +543,8 @@ Point2I GuiGameListMenuCtrl::getMinExtent() const
{ {
Point2I parentMin = Parent::getMinExtent(); Point2I parentMin = Parent::getMinExtent();
GuiGameListMenuProfile * profile = (GuiGameListMenuProfile *) mProfile; GuiGameListMenuProfile * profile = dynamic_cast<GuiGameListMenuProfile*>(mProfile);
AssertFatal(profile, "Invalid profile for GuiGameListMenuCtrl!");
S32 minHeight = 0; S32 minHeight = 0;
S32 rowHeight = profile->getRowHeight(); S32 rowHeight = profile->getRowHeight();
@ -631,6 +632,8 @@ void GuiGameListMenuCtrl::enforceConstraints()
} }
void GuiGameListMenuCtrl::updateHeight() void GuiGameListMenuCtrl::updateHeight()
{
if (hasValidProfile())
{ {
S32 minHeight = getMinExtent().y; S32 minHeight = getMinExtent().y;
if (getHeight() < minHeight) if (getHeight() < minHeight)
@ -638,6 +641,7 @@ void GuiGameListMenuCtrl::updateHeight()
setHeight(minHeight); setHeight(minHeight);
} }
} }
}
void GuiGameListMenuCtrl::onMouseDown(const GuiEvent &event) void GuiGameListMenuCtrl::onMouseDown(const GuiEvent &event)
{ {