Skip to content

Commit

Permalink
Merge pull request #74 from wro-ableton/fix-wmf-eof
Browse files Browse the repository at this point in the history
Fix potential integer overflow at end of stream in media_foundation_helper
  • Loading branch information
ni-mheppner authored Mar 1, 2024
2 parents 89eb1e3 + 27b6639 commit 319c7fe
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ template <class Source>
class SyncronousByteStream : public IMFByteStream
{

static constexpr auto endOfSequence = -1;

auto tell() -> std::streamsize
{
auto pos = m_source.seek( boost::iostreams::stream_offset( 0 ), BOOST_IOS::cur );
Expand All @@ -86,7 +88,8 @@ class SyncronousByteStream : public IMFByteStream

try
{
*read = static_cast<ULONG>( m_source.read( reinterpret_cast<char*>( buffer ), toRead ) );
const auto result = m_source.read( reinterpret_cast<char*>( buffer ), toRead );
*read = static_cast<ULONG>( result == endOfSequence ? 0 : result );
return S_OK;
}
catch ( const std::system_error& )
Expand Down

0 comments on commit 319c7fe

Please sign in to comment.