don't crash when xbox bios not specified

This commit is contained in:
espes 2013-03-31 09:07:09 +10:00
parent d4e5f72cb4
commit c3e6e90b36
1 changed files with 5 additions and 0 deletions

View File

@ -81,12 +81,17 @@ static void xbox_memory_init(MemoryRegion *system_memory,
} else {
bios_size = -1;
}
if (bios_size <= 0 ||
(bios_size % 65536) != 0) {
goto bios_error;
}
bios = g_malloc(sizeof(*bios));
memory_region_init_ram(bios, "xbox.bios", bios_size);
vmstate_register_ram_global(bios);
memory_region_set_readonly(bios, true);
ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
if (ret != 0) {
bios_error:
fprintf(stderr, "qemu: could not load xbox BIOS '%s'\n", bios_name);
exit(1);
}