Merge pull request #8149 from tlindner/wd177x-fix-segfault

wd177x: fix segfault based on track count
This commit is contained in:
ajrhacker 2021-06-06 19:10:50 -04:00 committed by GitHub
commit 43427547f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -212,11 +212,6 @@ bool wd177x_format::load(io_generic *io, uint32_t form_factor, const std::vector
return false;
}
if(f.head_count > max_heads) {
osd_printf_error("wd177x_format: Number of sides in image file too high for floppy drive (%d > %d)\n", f.track_count, max_heads);
return false;
}
for(int track=0; track < f.track_count; track++)
for(int head=0; head < f.head_count; head++) {
uint8_t sectdata[40*512];
@ -433,6 +428,15 @@ void wd177x_format::check_compatibility(floppy_image *image, std::vector<int> &c
int *ok_cands = &candidates[0];
for(unsigned int i=0; i < candidates.size(); i++) {
const format &f = formats[candidates[i]];
int max_tracks, max_heads;
image->get_maximal_geometry(max_tracks, max_heads);
// Fail if floppy drive can't handle track count
if(f.track_count > max_tracks) {
goto fail;
}
for(int track=0; track < f.track_count; track++) {
for(int head=0; head < f.head_count; head++) {
const format &tf = get_track_format(f, head, track);