diff --git a/libres_internal.h b/libres_internal.h index 57bd540..6308685 100644 --- a/libres_internal.h +++ b/libres_internal.h @@ -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[]; }; diff --git a/res.c b/res.c index 6ca5bdf..e347bd1 100644 --- a/res.c +++ b/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);