comparison arogue5/state.c @ 83:09db0cf536af

Properly handle invalid room references in savefiles. In all games, rs_write_room_reference() stored -1 for a nonexistent room, but rs_read_room_reference() did not check for out-of-bounds values, leading to pointers to rooms[-1], which sometimes caused crashes. rs_read_room_reference() has now been modified to use NULL instead. Some of the games required further changes to replace NULL with the pointer to the actual room. Others are capable of handling NULL for objects not in any room.
author John "Elwin" Edwards
date Thu, 08 Aug 2013 12:41:35 -0700
parents 19903deed392
children 5f51f7d9805f
comparison
equal deleted inserted replaced
82:f11eeafc6568 83:09db0cf536af
1659 if (read_error || format_error) 1659 if (read_error || format_error)
1660 return(READSTAT); 1660 return(READSTAT);
1661 1661
1662 rs_read_int(inf, &i); 1662 rs_read_int(inf, &i);
1663 1663
1664 *rp = &rooms[i]; 1664 if (i >= 0 && i < MAXROOMS)
1665 *rp = &rooms[i];
1666 else
1667 *rp = NULL;
1665 1668
1666 return(READSTAT); 1669 return(READSTAT);
1667 } 1670 }
1668 1671
1669 int 1672 int