Fix uninitialized signature access

`obj_get_signature()` examines all objects with a type other than
`OBJ_NONE` to find an unused signature.
`load_game_data()`->`read_object()` set an object's type before calling
`obj_get_signature()`, so `obj_get_signature()` would consider the
uninitialized signature of the newly loaded object for exclusion.
Reorder the initialization to compute the signature before the object is
given a type, then store the signature on the object after the poison
bytes (if any) are written.
This commit is contained in:
Kp 2016-11-19 17:24:53 +00:00
parent 382d337118
commit e0d24f242b

View file

@ -352,7 +352,9 @@ namespace dsx {
static void read_object(const vobjptr_t obj,PHYSFS_File *f,int version)
{
const auto poison_obj = reinterpret_cast<uint8_t *>(&*obj);
const auto signature = obj_get_signature();
DXX_POISON_MEMORY(poison_obj, sizeof(*obj), 0xfd);
obj->signature = signature;
obj->type = PHYSFSX_readByte(f);
obj->id = PHYSFSX_readByte(f);
@ -884,7 +886,6 @@ static int load_game_data(PHYSFS_File *LoadFile)
{
const auto &&o = vobjptr(&i);
read_object(o, LoadFile, game_top_fileinfo_version);
i.signature = obj_get_signature();
verify_object(o);
}
}