projects
/
open-adventure.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
5e39abf
)
Verify bounds for linked lists
author
NHOrus
<jy6x2b32pie9@yahoo.com>
Thu, 24 Aug 2017 10:47:57 +0000
(13:47 +0300)
committer
NHOrus
<jy6x2b32pie9@yahoo.com>
Thu, 24 Aug 2017 10:47:57 +0000
(13:47 +0300)
advent.h
patch
|
blob
|
history
saveresume.c
patch
|
blob
|
history
diff --git
a/advent.h
b/advent.h
index 6d8380738fdc8f48157a8876ce16934dd8266aca..17ae719d51231dc82430eb6eaec53278e0173123 100644
(file)
--- a/
advent.h
+++ b/
advent.h
@@
-165,7
+165,7
@@
struct game_t {
loc_t dloc[NDWARVES + 1]; // location of dwarves, initially hard-wired in
loc_t odloc[NDWARVES + 1]; // prior loc of each dwarf, initially garbage
loc_t fixed[NOBJECTS + 1]; // fixed location of object (if not IS_FREE)
loc_t dloc[NDWARVES + 1]; // location of dwarves, initially hard-wired in
loc_t odloc[NDWARVES + 1]; // prior loc of each dwarf, initially garbage
loc_t fixed[NOBJECTS + 1]; // fixed location of object (if not IS_FREE)
-
long
link[NOBJECTS * 2 + 1]; // object-list links
+
obj_t
link[NOBJECTS * 2 + 1]; // object-list links
loc_t place[NOBJECTS + 1]; // location of object
long hinted[NHINTS]; // hinted[i] = true iff hint i has been used.
long hintlc[NHINTS]; // hintlc[i] = how long at LOC with cond bit i
loc_t place[NOBJECTS + 1]; // location of object
long hinted[NHINTS]; // hinted[i] = true iff hint i has been used.
long hintlc[NHINTS]; // hintlc[i] = how long at LOC with cond bit i
diff --git
a/saveresume.c
b/saveresume.c
index 6027096abf1e6035ed4e2bad18dfcb4aed29e953..4378324c3b3fd5bf00437587727563c4f953e496 100644
(file)
--- a/
saveresume.c
+++ b/
saveresume.c
@@
-185,7
+185,7
@@
bool is_valid(struct game_t valgame)
}
/* Check that properties of objects aren't beyond expected */
}
/* Check that properties of objects aren't beyond expected */
- for (
in
t obj = 0; obj <= NOBJECTS; obj++) {
+ for (
obj_
t obj = 0; obj <= NOBJECTS; obj++) {
if (valgame.prop[obj] < STATE_NOTFOUND || valgame.prop[obj] > 1) {
switch (obj) {
case RUG:
if (valgame.prop[obj] < STATE_NOTFOUND || valgame.prop[obj] > 1) {
switch (obj) {
case RUG:
@@
-210,9
+210,14
@@
bool is_valid(struct game_t valgame)
}
}
}
}
- /* Check that
we have objects at location
s */
+ /* Check that
values in linked lists for objects in locations are inside bound
s */
for (loc_t loc = LOC_NOWHERE; loc <= NLOCATIONS; loc++) {
for (loc_t loc = LOC_NOWHERE; loc <= NLOCATIONS; loc++) {
- if (valgame.atloc[loc] < NO_OBJECT || valgame.atloc[loc] > NOBJECTS * 2 + 1) {
+ if (valgame.atloc[loc] < NO_OBJECT || valgame.atloc[loc] > NOBJECTS * 2) {
+ return false;
+ }
+ }
+ for (obj_t obj = 0; obj <= NOBJECTS * 2; obj++ ) {
+ if (valgame.link[obj] < NO_OBJECT || valgame.link[obj] > NOBJECTS * 2) {
return false;
}
}
return false;
}
}