Skip to content

Commit 2eec7ae

Browse files
Merge pull request #2230 from sixlettervariables/issue-2166-battlearmorsuit-null-stickerprice
Issue #2166: NRE in Money::plus/Money::minus
2 parents 9714fa3 + 29b7860 commit 2eec7ae

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

MekHQ/src/mekhq/campaign/finances/Money.java

+8
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ public Money absolute() {
102102
}
103103

104104
public Money plus(Money amount) {
105+
if (amount == null) {
106+
return plus(0L);
107+
}
108+
105109
return new Money(getWrapped().plus(amount.getWrapped()));
106110
}
107111

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

116120
public Money minus(Money amount) {
121+
if (amount == null) {
122+
return minus(0L);
123+
}
124+
117125
return new Money(getWrapped().minus(amount.getWrapped()));
118126
}
119127

MekHQ/src/mekhq/campaign/parts/BattleArmorSuit.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public Money getStickerPrice() {
235235
//if there are no linked parts and the unit is null,
236236
//then use the pre-recorded alternate costs
237237
if ((null == unit) && !hasChildParts()) {
238-
return alternateCost;
238+
return (alternateCost != null) ? alternateCost : Money.zero();
239239
}
240240
Money cost = Money.zero();
241241
switch(weightClass) {

0 commit comments

Comments
 (0)