[totem/wip/hadess/fix-browse-valgrind-warning: 12/12] main: Fix warning when "browsing too fast"



commit 3b49f9794c2b8c3a2ff0b17ecad1012516d4b02f
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Feb 28 17:33:07 2019 +0100

    main: Fix warning when "browsing too fast"
    
    Fix possible use of an uninitialised variable, as spotted by valgrind.
    
    (totem:28635): Gtk-CRITICAL **: 17:22:01.811: gtk_tree_model_get_iter: assertion 'path != NULL' failed
    ==28635== Conditional jump or move depends on uninitialised value(s)
    ==28635==    at 0x50BCC94: gtk_tree_store_get_value (gtktreestore.c:655)
    ==28635==    by 0x50AF14D: gtk_tree_model_get_valist (gtktreemodel.c:1798)
    ==28635==    by 0x50AF47C: gtk_tree_model_get (gtktreemodel.c:1762)
    ==28635==    by 0x48989C6: browse_cb (totem-grilo.c:688)
    ==28635==    by 0x608EFE3: queue_process (grl-source.c:2088)
    ==28635==    by 0x4994917: g_main_dispatch (gmain.c:3189)
    ==28635==    by 0x4994917: g_main_context_dispatch (gmain.c:3854)
    ==28635==    by 0x4994D07: g_main_context_iterate.isra.26 (gmain.c:3927)
    ==28635==    by 0x4994D9B: g_main_context_iteration (gmain.c:3988)
    ==28635==    by 0x4B3A71C: g_application_run (gapplication.c:2516)
    ==28635==    by 0x10A277: main (totem.c:83)
    
    See https://gitlab.gnome.org/GNOME/totem/issues/304

 src/totem-grilo.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/totem-grilo.c b/src/totem-grilo.c
index ea8413aba..3caac17ee 100644
--- a/src/totem-grilo.c
+++ b/src/totem-grilo.c
@@ -682,8 +682,11 @@ browse_cb (GrlSource    *source,
                        GtkTreePath *path;
 
                        path = gtk_tree_row_reference_get_path (bud->ref_parent);
-                       gtk_tree_model_get_iter (bud->model, &parent, path);
-                       gtk_tree_path_free (path);
+                       if (!path ||
+                           !gtk_tree_model_get_iter (bud->model, &parent, path)) {
+                               g_clear_pointer (&path, gtk_tree_path_free);
+                               return;
+                       }
 
                        gtk_tree_model_get (bud->model, &parent,
                                            MODEL_RESULTS_REMAINING, &remaining_expected,


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