Bugfix: use memmove() if source and destination range can overlap (found with valgrind).
This commit is contained in:
parent
902ed3f90b
commit
f35b9b23c8
@ -3164,7 +3164,7 @@ void bx_hard_drive_c::init_mode_sense_single(Bit8u channel, const void* src, int
|
||||
controller->buffer[7] = 0; // reserved
|
||||
|
||||
// Data
|
||||
memcpy(controller->buffer + 8, src, size);
|
||||
memmove(controller->buffer + 8, src, size);
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1)
|
||||
|
@ -310,7 +310,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;
|
||||
|
@ -1328,7 +1328,7 @@ Bit32u bx_sb16_c::dsp_adc_handler(Bit32u buflen)
|
||||
|
||||
len = DSP.dma.chunkcount - DSP.dma.chunkindex;
|
||||
if (len > 0) {
|
||||
memcpy(DSP.dma.chunk, DSP.dma.chunk+DSP.dma.chunkindex, len);
|
||||
memmove(DSP.dma.chunk, DSP.dma.chunk+DSP.dma.chunkindex, len);
|
||||
DSP.dma.chunkcount = len;
|
||||
}
|
||||
DSP.dma.chunkindex = 0;
|
||||
|
@ -310,7 +310,7 @@ int bx_sound_alsa_c::alsa_pcm_write()
|
||||
BX_ERROR(("ALSA: short write, write %d frames", ret));
|
||||
}
|
||||
alsa_pcm[0].audio_bufsize -= alsa_pcm[0].alsa_bufsize;
|
||||
memcpy(audio_buffer[0], audio_buffer[0]+alsa_pcm[0].alsa_bufsize, alsa_pcm[0].audio_bufsize);
|
||||
memmove(audio_buffer[0], audio_buffer[0]+alsa_pcm[0].alsa_bufsize, alsa_pcm[0].audio_bufsize);
|
||||
}
|
||||
if ((alsa_pcm[0].audio_bufsize == 0) && (alsa_pcm[0].buffer != NULL)) {
|
||||
free(alsa_pcm[0].buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user