[FFmpeg-devel] Re: [PATCH] matroskadec: check s->streams[k] before using it

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Mon May 4 13:24:08 CEST 2015


On 04.05.2015 12:39, Michael Niedermayer wrote:
> On Sun, May 03, 2015 at 11:55:20PM +0200, Andreas Cadhalpun wrote:
>> This fixes a segmentation fault.
>>
>> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
>> ---
>>  libavformat/matroskadec.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>> index 27d184e..31723b3 100644
>> --- a/libavformat/matroskadec.c
>> +++ b/libavformat/matroskadec.c
>> @@ -2012,7 +2012,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
>>                  snprintf(buf, sizeof(buf), "%s_%d",
>>                           ff_matroska_video_stereo_plane[planes[j].type], i);
>>                  for (k=0; k < matroska->tracks.nb_elem; k++)
>> -                    if (planes[j].uid == tracks[k].uid) {
>> +                    if (planes[j].uid == tracks[k].uid && s->streams[k]) {
>>                          av_dict_set(&s->streams[k]->metadata,
> 
> i suspect the code should be using tracks[k].stream instead of
> s->streams[k]

I suspected that as well, but it does not make a difference: it still crashes
without the explicit NULL check.
If you are sure that tracks[k].stream is correct, you can change it and the
check accordingly.

Best regards,
Andreas



More information about the ffmpeg-devel mailing list