[tracker-miners/wip/carlosg/gstreamer-mov] tracker-extract: Protect against NULL GstTagList




commit f796a010d6cfa1d4ae1a76c8c4833bd4591cb533
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Sep 17 23:25:11 2022 +0200

    tracker-extract: Protect against NULL GstTagList
    
    This list may be NULL, so protect against that happening. Fixes
    a number of runtime warnings on files that trigger the situation.
    
    Related: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/233

 src/tracker-extract/tracker-extract-gstreamer.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index f64413f72..f0e0861ba 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -1293,20 +1293,25 @@ discoverer_init_and_run (MetadataExtractor *extractor,
 
        for (l = extractor->streams; l; l = g_list_next (l)) {
                GstDiscovererStreamInfo *stream = l->data;
-               GstTagList *stream_tags;
+               GstTagList *stream_tags, *copy = NULL;
+
+               stream_tags = gst_discoverer_stream_info_get_tags (stream);
+
+               if (stream_tags)
+                       copy = gst_tag_list_copy (stream_tags);
 
-               stream_tags = gst_tag_list_copy (gst_discoverer_stream_info_get_tags (stream));
                if (extractor->has_video &&
+                   copy &&
                    gst_tag_list_get_tag_size (extractor->tagcache, "title") > 0)
-                       gst_tag_list_remove_tag (stream_tags, "title");
+                       gst_tag_list_remove_tag (copy, "title");
 
-               if (stream_tags) {
+               if (copy) {
                        gst_tag_list_insert (extractor->tagcache,
-                                            stream_tags,
+                                            copy,
                                             GST_TAG_MERGE_APPEND);
                }
 
-               gst_tag_list_unref (stream_tags);
+               g_clear_pointer (&copy, gst_tag_list_unref);
        }
 
        gst_discoverer_info_unref (info);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]