Commit 4dd10ad6 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: avi: fix reading WAVEFORMATEX extra

(cherry picked from commit e7d72a70)
parent 43a34ee9
...@@ -545,10 +545,13 @@ static int Open( vlc_object_t * p_this ) ...@@ -545,10 +545,13 @@ static int Open( vlc_object_t * p_this )
p_auds->p_wf->nSamplesPerSec, p_auds->p_wf->nSamplesPerSec,
p_auds->p_wf->wBitsPerSample ); p_auds->p_wf->wBitsPerSample );
if( p_auds->p_wf->cbSize > 0 && p_auds->i_chunk_size > sizeof(WAVEFORMATEX) ) const size_t i_cboff = sizeof(WAVEFORMATEX);
const size_t i_incboff = ( p_auds->p_wf->wFormatTag == WAVE_FORMAT_EXTENSIBLE ) ?
sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX): 0;
if( p_auds->i_chunk_size >= i_cboff + p_auds->p_wf->cbSize &&
p_auds->p_wf->cbSize > i_incboff )
{ {
int i_extra = __MIN( p_auds->p_wf->cbSize, int i_extra = p_auds->p_wf->cbSize - i_incboff;
p_auds->i_chunk_size - sizeof(WAVEFORMATEX) );
tk->fmt.p_extra = malloc( i_extra ); tk->fmt.p_extra = malloc( i_extra );
if( unlikely(tk->fmt.p_extra == NULL) ) if( unlikely(tk->fmt.p_extra == NULL) )
{ {
...@@ -557,7 +560,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -557,7 +560,7 @@ static int Open( vlc_object_t * p_this )
goto error; goto error;
} }
tk->fmt.i_extra = i_extra; tk->fmt.i_extra = i_extra;
memcpy( tk->fmt.p_extra, &p_auds->p_wf[1], tk->fmt.i_extra ); memcpy( tk->fmt.p_extra, ((uint8_t *)(&p_auds->p_wf[1])) + i_incboff, i_extra );
} }
break; break;
} }
......
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