Skip to content

Commit 319c7fe

Browse files
authored
Merge pull request #74 from wro-ableton/fix-wmf-eof
Fix potential integer overflow at end of stream in media_foundation_helper
2 parents 89eb1e3 + 27b6639 commit 319c7fe

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

audiostream/src/ni/media/audio/os/win/media_foundation_helper.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ template <class Source>
6565
class SyncronousByteStream : public IMFByteStream
6666
{
6767

68+
static constexpr auto endOfSequence = -1;
69+
6870
auto tell() -> std::streamsize
6971
{
7072
auto pos = m_source.seek( boost::iostreams::stream_offset( 0 ), BOOST_IOS::cur );
@@ -86,7 +88,8 @@ class SyncronousByteStream : public IMFByteStream
8688

8789
try
8890
{
89-
*read = static_cast<ULONG>( m_source.read( reinterpret_cast<char*>( buffer ), toRead ) );
91+
const auto result = m_source.read( reinterpret_cast<char*>( buffer ), toRead );
92+
*read = static_cast<ULONG>( result == endOfSequence ? 0 : result );
9093
return S_OK;
9194
}
9295
catch ( const std::system_error& )

0 commit comments

Comments
 (0)