Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/libchdr_chd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2005,14 +2005,14 @@ static chd_error hunk_read_into_memory(chd_file *chd, uint32_t hunknum, uint8_t
free(buf);
return err;
}
memcpy(dest, buf + unit_in_hunk * chd->header.unitbytes, (units_in_hunk - unit_in_hunk) * chd->header.unitbytes);
memcpy(dest, buf + (size_t)unit_in_hunk * chd->header.unitbytes, (size_t)(units_in_hunk - unit_in_hunk) * chd->header.unitbytes);
/* Read second half of hunk which contains blockoffs */
err = hunk_read_into_memory(chd->parent, (blockoffs / units_in_hunk) + 1, buf);
if (err != CHDERR_NONE) {
free(buf);
return err;
}
memcpy(dest + (units_in_hunk - unit_in_hunk) * chd->header.unitbytes, buf, unit_in_hunk * chd->header.unitbytes);
memcpy(dest + (size_t)(units_in_hunk - unit_in_hunk) * chd->header.unitbytes, buf, (size_t)unit_in_hunk * chd->header.unitbytes);
free(buf);
}
break;
Expand Down Expand Up @@ -2057,9 +2057,9 @@ static chd_error map_read(chd_file *chd)
entries = MAP_STACK_ENTRIES;

/* read that many */
if (!seek_and_read(chd, fileoffset, raw_map_entries, entries * entrysize))
if (!seek_and_read(chd, fileoffset, raw_map_entries, entries * (size_t)entrysize))
EARLY_EXIT(err = CHDERR_READ_ERROR);
fileoffset += entries * entrysize;
fileoffset += entries * (size_t)entrysize;

/* process that many */
if (entrysize == MAP_ENTRY_SIZE)
Expand Down