projects
/
open-adventure.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
36f72f1
)
Verify sanity of location arrays
author
NHOrus
<jy6x2b32pie9@yahoo.com>
Sun, 13 Aug 2017 14:16:09 +0000
(15:16 +0100)
committer
NHOrus
<jy6x2b32pie9@yahoo.com>
Sun, 13 Aug 2017 14:16:09 +0000
(15:16 +0100)
saveresume.c
patch
|
blob
|
history
diff --git
a/saveresume.c
b/saveresume.c
index 889794596ae2325e8500e909e7765f9f567b0a32..ecfc643d8f772ad82581b5cf9bcaa688f710c0c4 100644
(file)
--- a/
saveresume.c
+++ b/
saveresume.c
@@
-144,7
+144,21
@@
bool is_valid(struct game_t valgame)
valgame.oldloc < -1 || valgame.oldloc > NLOCATIONS) {
return false;
}
valgame.oldloc < -1 || valgame.oldloc > NLOCATIONS) {
return false;
}
+ /* Bounds check for location arrays
+ */
+ for (int i = 0; i <= NDWARVES; i++) {
+ if (valgame.dloc[i] < -1 || valgame.dloc[i] > NLOCATIONS ||
+ valgame.odloc[i] < -1 || valgame.odloc[i] > NLOCATIONS) {
+ return false;
+ }
+ }
+ for (int i = 0; i <= NOBJECTS; i++) {
+ if (valgame.place[i] < -1 || valgame.place[i] > NLOCATIONS ||
+ valgame.fixed[i] < -1 || valgame.fixed[i] > NLOCATIONS) {
+ return false;
+ }
+ }
return true;
}
return true;
}