Skip to content

Commit

Permalink
add patch to prevent crash on SCE followed by CPE
Browse files Browse the repository at this point in the history
hDecoder->element_alloced denotes whether or not we have allocated memory for
usage in terms of the specified channel element. Given that it previously only
had two states (1 meaning allocated, and 0 meaning not allocated), it would not
allocate enough memory for parsing a CPE it if is preceeded by a SCE (and
therefor crash).

These changes fixes the issue by making sure that we allocate additional memory
if so is necessary, and the set of values for hDecoder->element_alloced[n] is
now:

 0 = nothing allocated
 1 = allocated enough for SCE
 2 = allocated enough for CPE

All branches that depend on hDecoder->element_alloced[n] prior to this patch
only checks if the value is, or is not, zero. The added state, 2, is therefor
correctly handled automatically.

https://github.com/videolan/vlc/blob/master/contrib/src/faad2/faad2-fix-cpe-reconstruction.patch
  • Loading branch information
fabiangreffrath committed Jun 10, 2019
1 parent 942c3e0 commit f1f8e00
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libfaad/specrec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1109,13 +1109,13 @@ uint8_t reconstruct_channel_pair(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_s
#ifdef PROFILE
int64_t count = faad_get_ts();
#endif
if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0)
if (hDecoder->element_alloced[hDecoder->fr_ch_ele] != 2)
{
retval = allocate_channel_pair(hDecoder, cpe->channel, (uint8_t)cpe->paired_channel);
if (retval > 0)
return retval;

hDecoder->element_alloced[hDecoder->fr_ch_ele] = 1;
hDecoder->element_alloced[hDecoder->fr_ch_ele] = 2;
}

/* dequantisation and scaling */
Expand Down

0 comments on commit f1f8e00

Please sign in to comment.