Commit c2e0de71 authored by Filip Roséen's avatar Filip Roséen Committed by Jean-Baptiste Kempf
Browse files

mkv: replaced magic `10` by real constant + fixed initialization



Since `EbmlParser::m_el` has a fixed size we should take advantage of
this and actually pass `sizeof(m_el)` directly to `memset`; especially
since the old code only initializes the first 6 pointers when the array
can potentially store 10 elements.

The magic constant 10 has been replaced by `EbmlParser::M_EL_MAXSIZE` to
make the code easier to read, and safer to use.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 12a207b8
......@@ -40,7 +40,7 @@ EbmlParser::EbmlParser( EbmlStream *es, EbmlElement *el_start, demux_t *p_demux,
mb_dummy( b_with_dummy )
{
mi_remain_size[0] = el_start->GetSize();
memset( m_el, 0, 6 * sizeof( *m_el ) );
memset( m_el, 0, sizeof( *m_el ) * M_EL_MAXSIZE);
m_el[0] = el_start;
}
......@@ -253,7 +253,7 @@ EbmlElement *EbmlParser::Get( int n_call )
b_bad_position = true;
}
if( n_call < 10 && !b_bad_position && m_el[mi_level]->IsFiniteSize() &&
if( n_call < M_EL_MAXSIZE && !b_bad_position && m_el[mi_level]->IsFiniteSize() &&
( !m_el[mi_level-1]->IsFiniteSize() ||
m_el[mi_level]->GetEndPosition() <= m_el[mi_level-1]->GetEndPosition() ) )
{
......@@ -264,7 +264,7 @@ EbmlElement *EbmlParser::Get( int n_call )
}
else
{
/* Too large, misplaced or 10 successive dummy elements */
/* Too large, misplaced or M_EL_MAXSIZE successive dummy elements */
msg_Err( p_demux,
"Dummy element too large or misplaced at %" PRIu64 "... skipping to next upper element",
m_el[mi_level]->GetElementPosition() );
......
......@@ -51,10 +51,12 @@ class EbmlParser
bool IsTopPresent( EbmlElement * ) const;
private:
static const int M_EL_MAXSIZE = 10;
demux_t *p_demux;
EbmlStream *m_es;
int mi_level;
EbmlElement *m_el[10];
EbmlElement *m_el[M_EL_MAXSIZE];
int64_t mi_remain_size[10];
EbmlElement *m_got;
......
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