gst/mpegaudioparse/gstmpegaudioparse.c: Don't recurse from mp3parse_bytepos_to_time...
authorSebastian Dröge <slomo@circular-chaos.org>
Thu, 31 Jul 2008 14:35:40 +0000 (14:35 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Thu, 31 Jul 2008 14:35:40 +0000 (14:35 +0000)
Original commit message from CVS:
* gst/mpegaudioparse/gstmpegaudioparse.c:
(gst_mp3parse_sink_event), (gst_mp3parse_emit_frame),
(mp3parse_total_time), (mp3parse_bytepos_to_time):
Don't recurse from mp3parse_bytepos_to_time() to mp3parse_total_time()
if we're called from there already. Otherwise we end up in a endless
recursion and crash with a stack overflow.
This can happen when a Xing or VBRI header with TOC exists but it
doesn't contain the total time. Fixes bug #545370.

ChangeLog
gst/mpegaudioparse/gstmpegaudioparse.c

index 26ef92aa36b501194beff26d9b139438d6b6049f..d237e9f4ad5421b4398a50ae96dae49f4fc3b67f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-07-31  Sebastian Dröge  <sebastian.droege@collabora.co.uk>
+
+       * gst/mpegaudioparse/gstmpegaudioparse.c:
+       (gst_mp3parse_sink_event), (gst_mp3parse_emit_frame),
+       (mp3parse_total_time), (mp3parse_bytepos_to_time):
+       Don't recurse from mp3parse_bytepos_to_time() to mp3parse_total_time()
+       if we're called from there already. Otherwise we end up in a endless
+       recursion and crash with a stack overflow.
+
+       This can happen when a Xing or VBRI header with TOC exists but it
+       doesn't contain the total time. Fixes bug #545370.
+
 2008-07-31  Sebastian Dröge  <sebastian.droege@collabora.co.uk>
 
        * ext/lame/gstlame.c: (gst_lame_class_init),
index 815646a0177337e84f19a29f069e35bc702aa3e3..e9b3658aa76c781184a7bea73a39be2ff44be09a 100644 (file)
@@ -128,7 +128,7 @@ static GstStateChangeReturn gst_mp3parse_change_state (GstElement * element,
     GstStateChange transition);
 
 static gboolean mp3parse_bytepos_to_time (GstMPEGAudioParse * mp3parse,
-    gint64 bytepos, GstClockTime * ts);
+    gint64 bytepos, GstClockTime * ts, gboolean from_total_time);
 static gboolean
 mp3parse_total_bytes (GstMPEGAudioParse * mp3parse, gint64 * total);
 static gboolean
@@ -525,10 +525,10 @@ gst_mp3parse_sink_event (GstPad * pad, GstEvent * event)
         GstClockTime seg_start, seg_stop, seg_pos;
 
         /* stop time is allowed to be open-ended, but not start & pos */
-        if (!mp3parse_bytepos_to_time (mp3parse, stop, &seg_stop))
+        if (!mp3parse_bytepos_to_time (mp3parse, stop, &seg_stop, FALSE))
           seg_stop = GST_CLOCK_TIME_NONE;
-        if (mp3parse_bytepos_to_time (mp3parse, start, &seg_start) &&
-            mp3parse_bytepos_to_time (mp3parse, pos, &seg_pos)) {
+        if (mp3parse_bytepos_to_time (mp3parse, start, &seg_start, FALSE) &&
+            mp3parse_bytepos_to_time (mp3parse, pos, &seg_pos, FALSE)) {
           gst_event_unref (event);
           event = gst_event_new_new_segment_full (update, rate, applied_rate,
               GST_FORMAT_TIME, seg_start, seg_stop, seg_pos);
@@ -667,7 +667,7 @@ gst_mp3parse_emit_frame (GstMPEGAudioParse * mp3parse, guint size,
 
     /* No timestamp yet, convert our offset to a timestamp if we can, or
      * start at 0 */
-    if (mp3parse_bytepos_to_time (mp3parse, mp3parse->cur_offset, &ts) &&
+    if (mp3parse_bytepos_to_time (mp3parse, mp3parse->cur_offset, &ts, FALSE) &&
         GST_CLOCK_TIME_IS_VALID (ts))
       GST_BUFFER_TIMESTAMP (outbuf) = ts;
     else {
@@ -1550,7 +1550,7 @@ mp3parse_total_time (GstMPEGAudioParse * mp3parse, GstClockTime * total)
     return FALSE;
 
   if (total_bytes != -1
-      && !mp3parse_bytepos_to_time (mp3parse, total_bytes, total))
+      && !mp3parse_bytepos_to_time (mp3parse, total_bytes, total, TRUE))
     return FALSE;
 
   return TRUE;
@@ -1640,7 +1640,7 @@ no_bitrate:
 
 static gboolean
 mp3parse_bytepos_to_time (GstMPEGAudioParse * mp3parse,
-    gint64 bytepos, GstClockTime * ts)
+    gint64 bytepos, GstClockTime * ts, gboolean from_total_time)
 {
   gint64 total_bytes;
 
@@ -1657,7 +1657,7 @@ mp3parse_bytepos_to_time (GstMPEGAudioParse * mp3parse,
   }
 
   /* If XING seek table exists use this for byte->time conversion */
-  if ((mp3parse->xing_flags & XING_TOC_FLAG) &&
+  if (!from_total_time && (mp3parse->xing_flags & XING_TOC_FLAG) &&
       mp3parse_total_bytes (mp3parse, &total_bytes) &&
       mp3parse_total_time (mp3parse, &total_time)) {
     gdouble fa, fb, fx;
@@ -1679,7 +1679,7 @@ mp3parse_bytepos_to_time (GstMPEGAudioParse * mp3parse,
     return TRUE;
   }
 
-  if (mp3parse->vbri_seek_table &&
+  if (!from_total_time && mp3parse->vbri_seek_table &&
       mp3parse_total_bytes (mp3parse, &total_bytes) &&
       mp3parse_total_time (mp3parse, &total_time)) {
     gint i = 0;