Use memmove for overlapping copy

This commit is contained in:
Jakub Kądziołka 2021-02-27 18:29:59 +01:00
parent 03cbab2f85
commit 1dae345b24
No known key found for this signature in database
GPG Key ID: E315A75846131564

View File

@ -150,7 +150,7 @@ static bool verify_and_update_state_compatibility(GB_gameboy_t *gb, GB_gameboy_t
{ {
if (save->ram_size == 0 && (&save->ram_size)[-1] == gb->ram_size) { if (save->ram_size == 0 && (&save->ram_size)[-1] == gb->ram_size) {
/* This is a save state with a bad printer struct from a 32-bit OS */ /* This is a save state with a bad printer struct from a 32-bit OS */
memcpy(save->extra_oam + 4, save->extra_oam, (uintptr_t)&save->ram_size - (uintptr_t)&save->extra_oam); memmove(save->extra_oam + 4, save->extra_oam, (uintptr_t)&save->ram_size - (uintptr_t)&save->extra_oam);
} }
if (save->ram_size == 0) { if (save->ram_size == 0) {
/* Save doesn't have ram size specified, it's a pre 0.12 save state with potentially /* Save doesn't have ram size specified, it's a pre 0.12 save state with potentially