Skip to content
Merged
Show file tree
Hide file tree
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: 7 additions & 1 deletion src/devices/imagedev/floppy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/lib/formats/upd765_dsk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down