Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2016-03-25 18:28:36 +0100
committerStijn Buys <ingar@osirion.org>2016-03-25 18:28:36 +0100
commit8b41b0b34c916486bb792c43fe9d4bdcc16c804b (patch)
tree7d0e5b25aadcaaa60677f461ed5a737bccec22d8
parenta54668eeaece112aad19e0bfd5197924602be001 (diff)
Fixed a bad pointer bug when a ship explodes and ejects a weapon. Thanks to Thorn for finding it.
-rw-r--r--src/game/base/ship.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index cc583d9..b1e0574 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -450,6 +450,7 @@ void Ship::explode()
if ((*it)->info()->type() == Cargo::infotype()) {
long loss = (*it)->amount() * ((long) percentage) / 100l;
if (loss > 0) {
+ // eject potentially deletes the item the iterator is pointing to
eject((*it++), loss, false);
continue;
}
@@ -463,7 +464,9 @@ void Ship::explode()
while (it != inventory()->items().end()) {
if ((*it)->info()->type() == Weapon::infotype()) {
if (math::randomf(100.0f) < 10.0f) {
- eject((*it++), (*it)->amount(), false);
+ // eject potentially deletes the item the iterator is pointing to
+ float amount = (*it)->amount();
+ eject((*it++), amount, false);
continue;
}
}