Permalink
Browse files

Game::GetXPFromCR: avoid unlikely div-by-0

coverity 4347
  • Loading branch information...
1 parent 8d0d66e commit 22a0c872c15713d2c4a2977982ba4ac41343f54d @lynxlynxlynx lynxlynxlynx committed Apr 22, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 gemrb/core/Game.cpp
View
@@ -1159,7 +1159,9 @@ int Game::GetXPFromCR(int cr)
{
if (!crtable) LoadCRTable();
if (crtable) {
- int level = GetPartyLevel(true) / GetPartySize(true);
+ int size = GetPartySize(true);
+ if (!size) return 0; // everyone just died anyway
+ int level = GetPartyLevel(true) / size;
if (cr+1>=MAX_CRLEVEL) {
cr=MAX_CRLEVEL-2;
}

0 comments on commit 22a0c87

Please sign in to comment.