Skip to content

Commit

Permalink
Merge pull request #2230 from sixlettervariables/issue-2166-battlearm…
Browse files Browse the repository at this point in the history
…orsuit-null-stickerprice

Issue #2166: NRE in Money::plus/Money::minus
  • Loading branch information
sixlettervariables authored Nov 15, 2020
2 parents 9714fa3 + 29b7860 commit 2eec7ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions MekHQ/src/mekhq/campaign/finances/Money.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ public Money absolute() {
}

public Money plus(Money amount) {
if (amount == null) {
return plus(0L);
}

return new Money(getWrapped().plus(amount.getWrapped()));
}

Expand All @@ -114,6 +118,10 @@ public Money plus(List<Money> amounts) {
}

public Money minus(Money amount) {
if (amount == null) {
return minus(0L);
}

return new Money(getWrapped().minus(amount.getWrapped()));
}

Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/campaign/parts/BattleArmorSuit.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public Money getStickerPrice() {
//if there are no linked parts and the unit is null,
//then use the pre-recorded alternate costs
if ((null == unit) && !hasChildParts()) {
return alternateCost;
return (alternateCost != null) ? alternateCost : Money.zero();
}
Money cost = Money.zero();
switch(weightClass) {
Expand Down

0 comments on commit 2eec7ae

Please sign in to comment.