[vlc-devel] [PATCH 09/11] demux:mkv: do not seek to an invalid position
Steve Lhomme
robux4 at ycbcr.xyz
Tue Jan 2 16:38:16 CET 2018
---
modules/demux/mkv/matroska_segment_seeker.cpp | 41 +++++++++++++++------------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/modules/demux/mkv/matroska_segment_seeker.cpp b/modules/demux/mkv/matroska_segment_seeker.cpp
index dc4d0ea088..3f89a207ec 100644
--- a/modules/demux/mkv/matroska_segment_seeker.cpp
+++ b/modules/demux/mkv/matroska_segment_seeker.cpp
@@ -436,31 +436,35 @@ void
SegmentSeeker::mkv_jump_to( matroska_segment_c& ms, fptr_t fpos )
{
fptr_t i_cluster_pos = -1;
- ms.cluster = NULL;
+ if ( fpos != std::numeric_limits<SegmentSeeker::fptr_t>::max() )
{
- cluster_positions_t::iterator cluster_it = greatest_lower_bound(
- _cluster_positions.begin(), _cluster_positions.end(), fpos
- );
+ ms.cluster = NULL;
+ if ( !_cluster_positions.empty() )
+ {
+ cluster_positions_t::iterator cluster_it = greatest_lower_bound(
+ _cluster_positions.begin(), _cluster_positions.end(), fpos
+ );
- ms.es.I_O().setFilePointer( *cluster_it );
- ms.ep->reconstruct( &ms.es, ms.segment, &ms.sys.demuxer );
- }
+ ms.es.I_O().setFilePointer( *cluster_it );
+ ms.ep->reconstruct( &ms.es, ms.segment, &ms.sys.demuxer );
+ }
- while( ms.cluster == NULL || (
- ms.cluster->IsFiniteSize() && ms.cluster->GetEndPosition() < fpos ) )
- {
- if( !( ms.cluster = static_cast<KaxCluster*>( ms.ep->Get() ) ) )
+ while( ms.cluster == NULL || (
+ ms.cluster->IsFiniteSize() && ms.cluster->GetEndPosition() < fpos ) )
{
- msg_Err( &ms.sys.demuxer, "unable to read KaxCluster during seek, giving up" );
- return;
- }
+ if( !( ms.cluster = static_cast<KaxCluster*>( ms.ep->Get() ) ) )
+ {
+ msg_Err( &ms.sys.demuxer, "unable to read KaxCluster during seek, giving up" );
+ return;
+ }
- i_cluster_pos = ms.cluster->GetElementPosition();
+ i_cluster_pos = ms.cluster->GetElementPosition();
- add_cluster_position( i_cluster_pos );
+ add_cluster_position( i_cluster_pos );
- mark_range_as_searched( Range( i_cluster_pos, ms.es.I_O().getFilePointer() ) );
+ mark_range_as_searched( Range( i_cluster_pos, ms.es.I_O().getFilePointer() ) );
+ }
}
ms.ep->Down();
@@ -487,6 +491,7 @@ SegmentSeeker::mkv_jump_to( matroska_segment_c& ms, fptr_t fpos )
/* jump to desired position */
- ms.es.I_O().setFilePointer( fpos );
+ if ( fpos != std::numeric_limits<SegmentSeeker::fptr_t>::max() )
+ ms.es.I_O().setFilePointer( fpos );
}
--
2.14.2
More information about the vlc-devel
mailing list