Workaround for MT 06194 (potential segfault during floppy load)

This commit is contained in:
AJR 2016-05-01 10:26:28 -04:00
parent 41885e4203
commit b8c05fd084
2 changed files with 13 additions and 1 deletions

View File

@ -412,7 +412,13 @@ bool floppy_image_device::call_load()
}
image = global_alloc(floppy_image(tracks, sides, form_factor));
best_format->load(&io, form_factor, image);
if (!best_format->load(&io, form_factor, image))
{
seterror(IMAGE_ERROR_UNSUPPORTED, "Incompatible image format or corrupted data");
global_free(image);
image = nullptr;
return IMAGE_INIT_FAIL;
}
output_format = is_readonly() ? nullptr : best_format;
revolution_start_time = mon ? attotime::never : machine().time();

View File

@ -180,7 +180,13 @@ bool upd765_format::load(io_generic *io, UINT32 form_factor, floppy_image *image
if(type == -1)
return false;
// format shouldn't exceed image geometry
const format &f = formats[type];
int img_tracks, img_heads;
image->get_maximal_geometry(img_tracks, img_heads);
if (f.track_count > img_tracks || f.head_count > img_heads)
return false;
floppy_image_format_t::desc_e *desc;
int current_size;
int end_gap_index;