matroskdemux: do not use MapInfo.data after unmapping
authorThibault Saunier <tsaunier@igalia.com>
Wed, 3 Oct 2018 15:34:49 +0000 (17:34 +0200)
committerThibault Saunier <tsaunier@igalia.com>
Wed, 3 Oct 2018 15:39:33 +0000 (17:39 +0200)
And minor gst-indenting

gst/matroska/matroska-demux.c
gst/matroska/matroska-read-common.c

index 1ef7b42..b67112c 100644 (file)
@@ -376,10 +376,12 @@ gst_matroska_decode_buffer (GstMatroskaTrackContext * context, GstBuffer * buf)
 
   if (gst_matroska_decode_data (context->encodings, &data, &size,
           GST_MATROSKA_TRACK_ENCODING_SCOPE_FRAME, FALSE)) {
-    gst_buffer_unmap (out_buf, &map);
     if (data != map.data) {
+      gst_buffer_unmap (out_buf, &map);
       gst_buffer_unref (out_buf);
       out_buf = gst_buffer_new_wrapped (data, size);
+    } else {
+      gst_buffer_unmap (out_buf, &map);
     }
   } else {
     GST_DEBUG ("decode data failed");
@@ -399,11 +401,12 @@ gst_matroska_decode_buffer (GstMatroskaTrackContext * context, GstBuffer * buf)
 
     if (gst_matroska_parse_protection_meta (&data, &size, info_protect,
             &encrypted)) {
-      gst_buffer_unmap (out_buf, &map);
       if (data != map.data) {
-        GstBuffer *tmp_buf = out_buf;
-        out_buf =
-            gst_buffer_copy_region (tmp_buf, GST_BUFFER_COPY_ALL,
+        GstBuffer *tmp_buf;
+
+        gst_buffer_unmap (out_buf, &map);
+        tmp_buf = out_buf;
+        out_buf = gst_buffer_copy_region (tmp_buf, GST_BUFFER_COPY_ALL,
             gst_buffer_get_size (tmp_buf) - size, size);
         gst_buffer_unref (tmp_buf);
         if (encrypted)
@@ -411,6 +414,7 @@ gst_matroska_decode_buffer (GstMatroskaTrackContext * context, GstBuffer * buf)
         else
           gst_structure_free (info_protect);
       } else {
+        gst_buffer_unmap (out_buf, &map);
         gst_structure_free (info_protect);
       }
     } else {
@@ -2705,10 +2709,10 @@ gst_matroska_demux_handle_seek_event (GstMatroskaDemux * demux,
    * would be determined again when parsing, but anyway ... */
   seeksegment.duration = demux->common.segment.duration;
 
-  flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
-  keyunit = ! !(flags & GST_SEEK_FLAG_KEY_UNIT);
-  after = ! !(flags & GST_SEEK_FLAG_SNAP_AFTER);
-  before = ! !(flags & GST_SEEK_FLAG_SNAP_BEFORE);
+  flush = !!(flags & GST_SEEK_FLAG_FLUSH);
+  keyunit = !!(flags & GST_SEEK_FLAG_KEY_UNIT);
+  after = !!(flags & GST_SEEK_FLAG_SNAP_AFTER);
+  before = !!(flags & GST_SEEK_FLAG_SNAP_BEFORE);
 
   /* always do full update if flushing,
    * otherwise problems might arise downstream with missing keyframes etc */
index ffb393b..1208550 100644 (file)
@@ -2043,6 +2043,8 @@ gst_matroska_read_common_parse_metadata_id_simple_tag (GstMatroskaReadCommon *
     const gchar *matroska_tagname;
     const gchar *gstreamer_tagname;
   }
+
+  /* *INDENT-OFF* */
   tag_conv[] = {
     {
       /* The following list has the _same_ order as the one in Matroska spec. Please, don't mess it up. */
@@ -2177,11 +2179,14 @@ gst_matroska_read_common_parse_metadata_id_simple_tag (GstMatroskaReadCommon *
     GST_MATROSKA_TAG_ID_LICENSE, GST_TAG_LICENSE}, {    /* The license applied to the content (like Creative Commons variants). */
     GST_MATROSKA_TAG_ID_TERMS_OF_USE, GST_TAG_LICENSE}
   };
+  /* *INDENT-ON* */
   static const struct
   {
     const gchar *matroska_tagname;
     const gchar *gstreamer_tagname;
   }
+
+  /* *INDENT-OFF* */
   child_tag_conv[] = {
     {
     "TITLE/SORT_WITH=", GST_TAG_TITLE_SORTNAME}, {
@@ -2198,6 +2203,7 @@ gst_matroska_read_common_parse_metadata_id_simple_tag (GstMatroskaReadCommon *
     "LICENSE/URL=", GST_TAG_LICENSE_URI}, {
     "LICENSE/URL=", GST_TAG_LICENSE_URI}
   };
+  /* *INDENT-ON* */
   GstFlowReturn ret;
   guint32 id;
   gchar *value = NULL;