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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user