Fix T71621: VSE crashes when playing last frame of audio

Due to some floating point errors the last frame of a VSE audio strip can
cause integer overflow and crash Blender. This overflow was caused by a
cast from `int64_t` to `int` without prior check. The crash is fixed by
keeping the variable as `int64_t` for as long as possible.
This commit is contained in:
Sybren A. Stüvel 2019-11-21 10:01:01 +01:00
parent ba1e9ae473
commit 122ba774e0
Notes: blender-bot 2023-02-14 06:27:47 +01:00
Referenced by issue #71621, Blender Crashes Frequently with Timeline Scrub
1 changed files with 2 additions and 2 deletions

View File

@ -292,8 +292,8 @@ int FFMPEGReader::read_packet(void* opaque, uint8_t* buf, int buf_size)
{
FFMPEGReader* reader = reinterpret_cast<FFMPEGReader*>(opaque);
int size = std::min(buf_size, int(reader->m_membuffer->getSize() - reader->m_membufferpos));
int64_t remaining_buffer_size = reader->m_membuffer->getSize() - reader->m_membufferpos;
int64_t size = std::min(static_cast<int64_t>(buf_size), remaining_buffer_size);
if(size < 0)
return -1;