bochs: backport overlapping memcpy fix

Upstream SVN r12563: "Bugfix: use memmove() if source and destination
range can overlap (found with valgrind)."

(Manually backported, the code structure has significantly changed
before this fix.)

Change-Id: Id176fb5b0aca806908cfb06f06bb5a7221ccc9c4
This commit is contained in:
Horst Schirmeier
2016-08-06 17:29:30 +02:00
parent a2798cc2bf
commit fbd788f05e
3 changed files with 3 additions and 3 deletions

View File

@ -304,7 +304,7 @@ void bx_pci_ide_c::timer()
// To avoid buffer overflow reset buffer pointers and copy data if necessary
count = BX_PIDE_THIS s.bmdma[channel].buffer_top - BX_PIDE_THIS s.bmdma[channel].buffer_idx;
if (count > 0) {
memcpy(BX_PIDE_THIS s.bmdma[channel].buffer, BX_PIDE_THIS s.bmdma[channel].buffer_idx, count);
memmove(BX_PIDE_THIS s.bmdma[channel].buffer, BX_PIDE_THIS s.bmdma[channel].buffer_idx, count);
}
BX_PIDE_THIS s.bmdma[channel].buffer_top = BX_PIDE_THIS s.bmdma[channel].buffer + count;
BX_PIDE_THIS s.bmdma[channel].buffer_idx = BX_PIDE_THIS s.bmdma[channel].buffer;