Fix divide by zero error

Fixes #5674

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2016-09-09 11:53:37 -07:00
parent 530b93c318
commit 893f106189

View File

@ -27,8 +27,15 @@ public class SmsCharacterCalculator extends CharacterCalculator {
int messagesSpent = length[0];
int charactersSpent = length[1];
int charactersRemaining = length[2];
int maxMessageSize = (charactersSpent + charactersRemaining) / messagesSpent;
int maxMessageSize;
if (messagesSpent > 0) {
maxMessageSize = (charactersSpent + charactersRemaining) / messagesSpent;
} else {
maxMessageSize = (charactersSpent + charactersRemaining);
}
return new CharacterState(messagesSpent, charactersRemaining, maxMessageSize);
}
}