mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
Fix invalid std::vector<> lookup in aviio.cpp
This fixes a case where: * m_soundbuf_samples == processedsamples * processedsamples > 0 * processedsamples * stream->channels() == m_soundbuf.size() In this scenario, the std::memmove() would do nothing (moving zero bytes), but the operator[] on the second parameter to std::memmove() overflows the array. This can be benign in optimized builds (because the third parameter to std::memmove() is 0), but on debugging builds this can cause an assert.
This commit is contained in:
parent
e896b3914e
commit
66f7e4fe0c
@ -3550,7 +3550,8 @@ avi_file::error avi_file_impl::soundbuf_flush(bool only_flush_full)
|
||||
if (processedsamples > 0)
|
||||
{
|
||||
/* first account for the samples we processed */
|
||||
std::memmove(&m_soundbuf[0], &m_soundbuf[processedsamples * stream->channels()], (m_soundbuf_samples - processedsamples) * bytes_per_sample);
|
||||
if (m_soundbuf_samples > processedsamples)
|
||||
std::memmove(&m_soundbuf[0], &m_soundbuf[processedsamples * stream->channels()], (m_soundbuf_samples - processedsamples) * bytes_per_sample);
|
||||
for (int channel = 0; channel < stream->channels(); channel++)
|
||||
m_soundbuf_chansamples[channel] -= processedsamples;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user