additional readArray protection (might cause regression in FT, but then we should fix FT!)

svn-id: r7512
This commit is contained in:
Max Horn 2003-05-14 20:14:03 +00:00
parent af8cb44727
commit eb22ea3b96

View file

@ -393,7 +393,7 @@ int Scumm_v6::popRoomAndObj(int *room) {
int Scumm::readArray(int array, int idx, int base) {
ArrayHeader *ah = (ArrayHeader *)getResourceAddress(rtString, readVar(array));
if (ah == NULL) {
if (ah == NULL || ah->data == NULL) {
error("readArray: invalid array %d (%d)", array, readVar(array));
}
@ -401,7 +401,10 @@ int Scumm::readArray(int array, int idx, int base) {
// FIXME: comment this for the time being as it was causing ft to crash
// in the minefeild
//assert(base >= 0 && base < ah->dim1_size * ah->dim2_size);
// FIX THE FIXME: fixing an assert by commenting out is bad. It's evil.
// It's wrong. Find the proper cause, or at least, silently return
// from the function, but don't just go on overwriting memory!
assert(base >= 0 && base < ah->dim1_size * ah->dim2_size);
if (ah->type == 4) {
return ah->data[base];