mpegts: Fix assertion fault in ISO 639 parsing
authorJesper Larsen <knorr.jesper@gmail.com>
Thu, 10 Oct 2013 20:46:48 +0000 (22:46 +0200)
committerEdward Hervey <edward@collabora.com>
Fri, 11 Oct 2013 08:20:57 +0000 (10:20 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=709180

gst-libs/gst/mpegts/gstmpegtsdescriptor.c

index aca1ece..c3c71f1 100644 (file)
@@ -639,7 +639,7 @@ gst_mpegts_descriptor_parse_iso_639_language (const GstMpegTsDescriptor *
  * @descriptor: a %GST_MTS_DESC_ISO_639_LANGUAGE #GstMpegTsDescriptor
  * @idx: Table id of the language to parse
  * @lang (out) (transfer none): 4-byte gchar array to hold the language code
- * @audio_type: (out) (transfer none): the #GstMpegTsIso639AudioType to set
+ * @audio_type: (out) (transfer none) (allow-none): the #GstMpegTsIso639AudioType to set
  *
  * Extracts the iso 639-2 language information from specific table id in @descriptor.
  *
@@ -659,17 +659,19 @@ gst_mpegts_descriptor_parse_iso_639_language_idx (const GstMpegTsDescriptor *
   g_return_val_if_fail (lang != NULL, FALSE);
   g_return_val_if_fail (descriptor->tag == GST_MTS_DESC_ISO_639_LANGUAGE,
       FALSE);
-  g_return_val_if_fail (audio_type != NULL, FALSE);
-  g_return_val_if_fail (descriptor->length / 4 > idx, FALSE);
+
+  if (descriptor->length / 4 <= idx)
+    return FALSE;
 
   data = (guint8 *) descriptor->data + 2 + idx * 4;
 
   memcpy (lang, data, 3);
-  *lang[3] = 0;
+  (*lang)[3] = 0;
 
   data += 3;
 
-  *audio_type = *data;
+  if (audio_type)
+    *audio_type = *data;
 
   return TRUE;
 }