diff options
author | rubidium <rubidium@openttd.org> | 2010-12-31 15:53:46 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-12-31 15:53:46 +0000 |
commit | 64c7cc51b5d24b1957ec1c7e8fd919d6783ab543 (patch) | |
tree | f5b375314297596001c75858df5100985ae4739e /src | |
parent | 582472d6269c610c6338e26360be38e1fc30ea9b (diff) | |
download | openttd-64c7cc51b5d24b1957ec1c7e8fd919d6783ab543.tar.xz |
(svn r21679) -Fix (r21642): reading a just freed variable
Diffstat (limited to 'src')
-rw-r--r-- | src/vehicle.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ce1f2abba..219ac872d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1747,9 +1747,10 @@ void Vehicle::BeginLoading() current_order.MakeLoading(true); UpdateVehicleTimetable(this, true); - for (Order *order = this->GetOrder(this->cur_order_index); - order != NULL && order->IsType(OT_AUTOMATIC); - order = order->next) { + const Order *order = this->GetOrder(this->cur_order_index); + while (order != NULL && order->IsType(OT_AUTOMATIC)) { + /* Delete order effectively deletes order, so get the next before deleting it. */ + order = order->next; DeleteOrder(this, this->cur_order_index); } |