[vhd] fix VHDX being inadvertently saved as VHD

* Addresses the error reported in #2468.
* Also use memmove instead of memcpy where overlapping data is involved.
This commit is contained in:
Pete Batard 2024-05-12 13:06:23 +01:00
parent fb43dc8957
commit 45423becd5
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
3 changed files with 10 additions and 9 deletions

View file

@ -1148,8 +1148,9 @@ void VhdSaveImage(void)
img_save.ImagePath = FileDialog(TRUE, NULL, &img_ext, &i);
if (img_save.ImagePath == NULL)
goto out;
for (i = 1; i <= (UINT)img_ext.count && (strstr(img_save.ImagePath, &_img_ext_x[i - 1][1]) == NULL); i++);
if (i > (UINT)img_ext.count) {
// Start from the end of our extension array, since '.vhd' would match for '.vhdx' otherwise
for (i = (UINT)img_ext.count; (i > 0) && (strstr(img_save.ImagePath, &_img_ext_x[i - 1][1]) == NULL); i--);
if (i == 0) {
uprintf("Warning: Can not determine image type from extension - Saving to uncompressed VHD.");
i = image_type_vhd;
} else {