TheAssemblyArmada / Thyme

An open source re-implementation of Generals : Zero Hour written in C++.
GNU General Public License v2.0
585 stars 59 forks source link

null dereference in Hide_Control_Bar #1057

Open xezon opened 9 months ago

xezon commented 9 months ago
void Hide_Control_Bar(bool immediate)
{
    Hide_Replay_Controls();

    if (g_theControlBar != nullptr) {
        g_theControlBar->Hide_Special_Power_Shortcut();
    }

    if (g_theWindowManager != nullptr) {
        GameWindow *window = g_theWindowManager->Win_Get_Window_From_Id(
            nullptr, g_theNameKeyGenerator->Name_To_Key("ControlBar.wnd:ControlBarParent"));

        if (window != nullptr) {
            g_theTacticalView->Set_Height(g_theDisplay->Get_Height());
        }

        if (immediate) {
            window->Win_Hide(true);

            if (g_theControlBar != nullptr) {
                g_theControlBar->Hide_Special_Power_Shortcut();
            }
        } else {
            g_theControlBar->m_controlBarAnimateWindowManager->Reverse_Animate_Window(); // no null check here
            g_theControlBar->Animate_Special_Power_Shortcut(false);
        }

        if (g_theControlBar != nullptr) {
            g_theControlBar->Hide_Purchase_Science();
        }
    }
}