Browse code

Fix crash when decoding DV in AVI introduced in r24579 (issue 2174).

Patch by Andrew Wason, rectalogic rectalogic com

Originally committed as revision 25023 to svn://svn.ffmpeg.org/ffmpeg/trunk

Andrew Wason authored on 2010/09/02 20:51:32
Showing 1 changed files
... ...
@@ -759,7 +759,7 @@ static AVStream *get_subtitle_pkt(AVFormatContext *s, AVStream *next_st,
759 759
     for (i=0; i<s->nb_streams; i++) {
760 760
         st  = s->streams[i];
761 761
         ast = st->priv_data;
762
-        if (st->discard < AVDISCARD_ALL && ast->sub_pkt.data) {
762
+        if (st->discard < AVDISCARD_ALL && ast && ast->sub_pkt.data) {
763 763
             ts = av_rescale_q(ast->sub_pkt.dts, st->time_base, AV_TIME_BASE_Q);
764 764
             if (ts <= next_ts && ts < ts_min) {
765 765
                 ts_min = ts;
... ...
@@ -1294,12 +1294,14 @@ static int avi_read_close(AVFormatContext *s)
1294 1294
         AVStream *st = s->streams[i];
1295 1295
         AVIStream *ast = st->priv_data;
1296 1296
         av_free(st->codec->palctrl);
1297
+        if (ast) {
1297 1298
         if (ast->sub_ctx) {
1298 1299
             av_freep(&ast->sub_ctx->pb);
1299 1300
             av_close_input_stream(ast->sub_ctx);
1300 1301
         }
1301 1302
         av_free(ast->sub_buffer);
1302 1303
         av_free_packet(&ast->sub_pkt);
1304
+        }
1303 1305
     }
1304 1306
 
1305 1307
     if (avi->dv_demux)