diff options
author | Bardur Arantsson <bardur@scientician.net> | 2013-09-08 11:49:32 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2013-09-27 14:46:43 +0200 |
commit | 88767d9fd11638b90e16da05426b19da9ef2b9b9 (patch) | |
tree | 185a93139f9b119bbdebd840cda377d1550c93a8 /src/init1.cc | |
parent | 7e88e06c6ea90c48c225ac89a7d7685dfa76cd65 (diff) |
Fix an overflow with allocation values
Diffstat (limited to 'src/init1.cc')
-rw-r--r-- | src/init1.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/init1.cc b/src/init1.cc index 076ca70e..646e8083 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -4393,6 +4393,11 @@ errr init_k_info_txt(FILE *fp, char *buf) /* XXX XXX XXX Simply read each number following a colon */ for (i = 0, s = buf + 1; s && (s[0] == ':') && s[1]; ++i) { + if (i >= ALLOCATION_MAX) { + msg_print("Too many allocation entries."); + return 1; + } + /* Default chance */ k_ptr->chance[i] = 1; @@ -4409,7 +4414,9 @@ errr init_k_info_txt(FILE *fp, char *buf) if (t && (!s || t < s)) { int chance = atoi(t + 1); - if (chance > 0) k_ptr->chance[i] = chance; + if (chance > 0) { + k_ptr->chance[i] = chance; + } } } |