[mythtv] [PATCH] frontend SEGV crash with patch -- ignore invalid codecs

Derek Atkins warlord at MIT.EDU
Mon Nov 17 13:44:02 EST 2003


Hi,

I've got a video that will consistently crash the frontend.  The
problem appears to be that there are a few bad packets in the video
which lead to a third stream, but that third stream has no codec
associated with it.

This patch will:

1) Ignore packets that don't have a valid codec, and
2) Don't "close" a non-existant codec.

This seems to fix the problem for me.

-derek

Index: libs/libmythtv/avformatdecoder.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/avformatdecoder.cpp,v
retrieving revision 1.64
diff -u -r1.64 avformatdecoder.cpp
--- libs/libmythtv/avformatdecoder.cpp	15 Nov 2003 00:56:02 -0000	1.64
+++ libs/libmythtv/avformatdecoder.cpp	17 Nov 2003 18:42:42 -0000
@@ -62,7 +62,8 @@
         for (int i = 0; i < ic->nb_streams; i++) 
         {
             AVStream *st = ic->streams[i];
-            avcodec_close(&st->codec);
+            if (st->codec.codec)
+                avcodec_close(&st->codec);
         } 
 
         ic->iformat->flags |= AVFMT_NOFILE;
@@ -1000,6 +1006,13 @@
             }
         }
  
+        if (!curstream->codec.codec)
+        {
+            cerr << "no codec for stream index " << pkt->stream_index << endl;
+            av_free_packet(pkt);
+            continue;
+        }
+
         firstloop = true;
 
         while (len > 0)


-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the mythtv-dev mailing list