Commit fcc89438 authored by Denis Charmet's avatar Denis Charmet Committed by Jean-Baptiste Kempf

Avoid double free in case of corrupted files

(cherry picked from commit 6cca95fb3950f4e2a1cdb2cfa2bc96538dd897a6)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 0c2125a8
...@@ -121,6 +121,11 @@ void EbmlParser::Keep( void ) ...@@ -121,6 +121,11 @@ void EbmlParser::Keep( void )
mb_keep = true; mb_keep = true;
} }
void EbmlParser::Unkeep()
{
mb_keep = false;
}
int EbmlParser::GetLevel( void ) const int EbmlParser::GetLevel( void ) const
{ {
return mi_user_level; return mi_user_level;
......
...@@ -41,6 +41,7 @@ class EbmlParser ...@@ -41,6 +41,7 @@ class EbmlParser
void Reset( demux_t *p_demux ); void Reset( demux_t *p_demux );
EbmlElement *Get( int n_call = 0 ); EbmlElement *Get( int n_call = 0 );
void Keep( void ); void Keep( void );
void Unkeep( void );
EbmlElement *UnGet( uint64 i_block_pos, uint64 i_cluster_pos ); EbmlElement *UnGet( uint64 i_block_pos, uint64 i_cluster_pos );
int GetLevel( void ) const; int GetLevel( void ) const;
......
...@@ -1502,7 +1502,7 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s ...@@ -1502,7 +1502,7 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
/* Check blocks validity to protect againts broken files */ /* Check blocks validity to protect againts broken files */
if( BlockFindTrackIndex( NULL, pp_block , pp_simpleblock ) ) if( BlockFindTrackIndex( NULL, pp_block , pp_simpleblock ) )
{ {
delete pp_block; ep->Unkeep();
pp_simpleblock = NULL; pp_simpleblock = NULL;
pp_block = NULL; pp_block = NULL;
continue; continue;
...@@ -1625,6 +1625,9 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s ...@@ -1625,6 +1625,9 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
{ {
msg_Err( &sys.demuxer, "Error while reading %s... upping level", typeid(*el).name()); msg_Err( &sys.demuxer, "Error while reading %s... upping level", typeid(*el).name());
ep->Up(); ep->Up();
ep->Unkeep();
pp_simpleblock = NULL;
pp_block = NULL;
break; break;
} }
if( MKV_IS_ID( el, KaxBlock ) ) if( MKV_IS_ID( el, KaxBlock ) )
...@@ -1678,6 +1681,9 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s ...@@ -1678,6 +1681,9 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
{ {
msg_Err( &sys.demuxer, "Error while reading %s... upping level", typeid(*el).name()); msg_Err( &sys.demuxer, "Error while reading %s... upping level", typeid(*el).name());
ep->Up(); ep->Up();
ep->Unkeep();
pp_simpleblock = NULL;
pp_block = NULL;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment