fix(ui): avoid potential null pointer issue in CSimpleButton::SetFontString

This commit is contained in:
fallenoak 2025-12-01 16:36:08 -06:00
parent 25780ae857
commit a9364386d8
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D

View File

@ -491,18 +491,10 @@ void CSimpleButton::SetFontString(CSimpleFontString* text) {
if (text) { if (text) {
text->SetFrame(this, DRAWLAYER_ARTWORK, 1); text->SetFrame(this, DRAWLAYER_ARTWORK, 1);
}
if (!text->Sub482AC0()) { if (!text->Sub482AC0()) {
auto font = this->m_normalFont; auto font = this->m_normalFont;
uint32_t styleFlags = font ? font->m_attributes.m_styleFlags : 0x0;
int32_t styleFlags;
if (font) {
styleFlags = font->m_attributes.m_styleFlags;
} else {
styleFlags = 0;
}
float offsetX = 0.0f; float offsetX = 0.0f;
float offsetY = 0.0f; float offsetY = 0.0f;
@ -515,6 +507,7 @@ void CSimpleButton::SetFontString(CSimpleFontString* text) {
text->SetPoint(FRAMEPOINT_CENTER, this, FRAMEPOINT_CENTER, offsetX, offsetY, 1); text->SetPoint(FRAMEPOINT_CENTER, this, FRAMEPOINT_CENTER, offsetX, offsetY, 1);
} }
} }
}
this->m_text = text; this->m_text = text;