diff --git a/src/3rdparty/squirrel/squirrel/sqcompiler.cpp b/src/3rdparty/squirrel/squirrel/sqcompiler.cpp index b9eace1c63..35fcc9e499 100644 --- a/src/3rdparty/squirrel/squirrel/sqcompiler.cpp +++ b/src/3rdparty/squirrel/squirrel/sqcompiler.cpp @@ -66,7 +66,7 @@ public: static SQChar temp[256]; va_list vl; va_start(vl, s); - scvsprintf(temp, s, vl); + scvsnprintf(temp, sizeof(temp), s, vl); va_end(vl); throw temp; } diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp index a66c44dcb4..59a6b29f86 100644 --- a/src/saveload/order_sl.cpp +++ b/src/saveload/order_sl.cpp @@ -295,7 +295,12 @@ void Load_BKOR() * Furthermore before savegame version 192 the actual content was always corrupt. */ if (!_networking || _network_server || IsSavegameVersionBefore(192)) { - _order_backup_pool.CleanPool(); + /* Note: We cannot use CleanPool since that skips part of the destructor + * and then leaks un-reachable Orders in the order pool. */ + OrderBackup *ob; + FOR_ALL_ORDER_BACKUPS(ob) { + delete ob; + } } } diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index 0da0ee5df2..6d86ce5de4 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -539,7 +539,7 @@ static void Load_STNN() for (uint32 j = 0; j < _num_flows; ++j) { SlObject(&flow, _flow_desc); if (fs == NULL || prev_source != flow.source) { - fs = &(st->goods[i].flows.insert(std::make_pair(flow.source, FlowStat(flow.via, flow.share))).first->second); + fs = &(st->goods[i].flows.insert(std::make_pair(flow.source, FlowStat(flow.via, flow.share, flow.restricted))).first->second); } else { fs->AppendShare(flow.via, flow.share, flow.restricted); } diff --git a/src/script/api/script_list.cpp b/src/script/api/script_list.cpp index 68df5bf956..44ebdde3ec 100644 --- a/src/script/api/script_list.cpp +++ b/src/script/api/script_list.cpp @@ -354,7 +354,12 @@ public: this->has_no_more_items = true; return; } - this->item_iter--; + if (this->item_iter == this->list->items.begin()) { + /* Use 'end' as marker for 'beyond begin' */ + this->item_iter = this->list->items.end(); + } else { + this->item_iter--; + } if (this->item_iter != this->list->items.end()) item_next = (*this->item_iter).first; } diff --git a/src/station_base.h b/src/station_base.h index 40bbf585b6..3c07075135 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -48,12 +48,13 @@ public: * Create a FlowStat with an initial entry. * @param st Station the initial entry refers to. * @param flow Amount of flow for the initial entry. + * @param restricted If the flow to be added is restricted. */ - inline FlowStat(StationID st, uint flow) + inline FlowStat(StationID st, uint flow, bool restricted = false) { assert(flow > 0); this->shares[flow] = st; - this->unrestricted = flow; + this->unrestricted = restricted ? 0 : flow; } /**