1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-17 01:12:39 +01:00

Codefix: possible null pointer dereference

This commit is contained in:
Rubidium
2025-12-13 23:07:39 +01:00
committed by rubidium42
parent 0ec8842232
commit a3393af26c

View File

@@ -1010,13 +1010,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();