mirror of https://github.com/zydeco/libres.git
fix crash when reading empty resource maps
This commit is contained in:
parent
2562781a7e
commit
4255947fe4
|
@ -68,13 +68,13 @@ struct __attribute__ ((__packed__)) RfMap {
|
|||
struct __attribute__ ((__packed__)) RfTypeEntry {
|
||||
// resource type entry
|
||||
uint32_t type; // resource type
|
||||
uint16_t count; // number of resources minus one
|
||||
int16_t count; // number of resources minus one
|
||||
uint16_t offset; // offset to ref list from type list
|
||||
};
|
||||
|
||||
struct __attribute__ ((__packed__)) RfTypeList {
|
||||
// resource type list
|
||||
uint16_t count; // minus one
|
||||
int16_t count; // minus one
|
||||
struct RfTypeEntry entry[];
|
||||
};
|
||||
|
||||
|
|
2
res.c
2
res.c
|
@ -280,7 +280,7 @@ RFILE* res_load (RFILE *rp) {
|
|||
uint8_t *names = ((void*)map)+ntohs(map->nameListOffset);
|
||||
|
||||
// read types
|
||||
rp->numTypes = 1+ntohs(types->count);
|
||||
rp->numTypes = 1+(int16_t)ntohs(types->count);
|
||||
rp->types = calloc(rp->numTypes, sizeof(struct RmType));
|
||||
if (rp->types == NULL) egoto(ENOMEM, error);
|
||||
bzero(rp->types, sizeof(struct RmType) * rp->numTypes);
|
||||
|
|
Loading…
Reference in New Issue