[easytag/easytag-2-2] Avoid a crash when browsing hidden directories



commit b60e4ac08252861be1f25517094ea49b8f3e7bb8
Author: David King <amigadave amigadave com>
Date:   Sun May 18 14:24:45 2014 +0100

    Avoid a crash when browsing hidden directories
    
    If viewing hidden directories is disabled, EasyTAG will fail to find a
    hidden path in the directory model, and will crash when trying to
    retrieve the full path from the model. Avoid this by returning early
    from Browser_Tree_Select_Dir().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730326

 src/browser.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index f80d90c..3027ec5 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -915,6 +915,7 @@ gboolean Browser_Tree_Select_Dir (const gchar *current_path)
             g_object_unref (file);
             g_free (path);
         }
+
         do
         {
             gtk_tree_model_get(GTK_TREE_MODEL(directoryTreeModel), &currentNode,
@@ -931,7 +932,16 @@ gboolean Browser_Tree_Select_Dir (const gchar *current_path)
                 break;
             }
             g_free(nodeName);
-        } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(directoryTreeModel), &currentNode));
+
+            if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (directoryTreeModel),
+                                           &currentNode))
+            {
+                /* Path was not found in tree, such as when a hidden path was
+                 * passed in, but hidden paths are set to not be displayed. */
+                g_strfreev (parts);
+                return FALSE;
+            }
+        } while (1);
 
         parentNode = currentNode;
         rootPath = gtk_tree_model_get_path(GTK_TREE_MODEL(directoryTreeModel), &parentNode);


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