summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-31 15:53:46 +0000
committerrubidium <rubidium@openttd.org>2010-12-31 15:53:46 +0000
commit64c7cc51b5d24b1957ec1c7e8fd919d6783ab543 (patch)
treef5b375314297596001c75858df5100985ae4739e /src
parent582472d6269c610c6338e26360be38e1fc30ea9b (diff)
downloadopenttd-64c7cc51b5d24b1957ec1c7e8fd919d6783ab543.tar.xz
(svn r21679) -Fix (r21642): reading a just freed variable
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp7
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);
}