Codefix: possible null pointer dereference

This commit is contained in:
Rubidium
2025-12-13 23:07:39 +01:00
committed by dP
parent b9069ca358
commit a482863544

View File

@@ -1049,13 +1049,15 @@ struct QueryStringWindow : public Window
void Close([[maybe_unused]] int data = 0) override
{
if (this->parent->window_class == WC_STATION_VIEW) SetViewportStationRect(Station::Get(this->parent->window_number), false);
if (this->parent->window_class == WC_WAYPOINT_VIEW) SetViewportWaypointRect(Waypoint::Get(this->parent->window_number), false);
if (this->parent != nullptr) {
if (this->parent->window_class == WC_STATION_VIEW) SetViewportStationRect(Station::Get(this->parent->window_number), false);
if (this->parent->window_class == WC_WAYPOINT_VIEW) SetViewportWaypointRect(Waypoint::Get(this->parent->window_number), false);
if (!this->editbox.handled && this->parent != nullptr) {
Window *parent = this->parent;
this->parent = nullptr; // so parent doesn't try to close us again
parent->OnQueryTextFinished(std::nullopt);
if (!this->editbox.handled) {
Window *parent = this->parent;
this->parent = nullptr; // so parent doesn't try to close us again
parent->OnQueryTextFinished(std::nullopt);
}
}
this->Window::Close();