Git Repositories

Fix crashes when reloading target file after move (bug #11983)
authorHarald Judt <h.judt@gmx.at>
Thu, 2 Jul 2015 08:30:21 +0000 (10:30 +0200)
committerHarald Judt <h.judt@gmx.at>
Fri, 3 Jul 2015 08:59:19 +0000 (10:59 +0200)
When moving a file, check the target file for NULL to avoid crashes
or assertions.

thunar/thunar-file.c
thunar/thunar-folder.c

index 196bb6c..3262dfb 100644 (file)
@@ -795,13 +795,15 @@ thunar_file_monitor (GFileMonitor     *monitor,
       if (event_type == G_FILE_MONITOR_EVENT_MOVED)
         {
           /* reload the target file if cached */
+          if (other_path == NULL)
+            return;
           other_file = thunar_file_cache_lookup (other_path);
           if (other_file)
               thunar_file_reload (other_file);
           else
               other_file = thunar_file_get (other_path, NULL);
 
-          if (!other_file)
+          if (other_file == NULL)
               return;
 
           /* notify the thumbnail cache that we can now also move the thumbnail */
index 217610a..9decb89 100644 (file)
@@ -773,27 +773,30 @@ thunar_folder_monitor (GFileMonitor     *monitor,
             {
               /* destroy the old file and update the new one */
               thunar_file_destroy (lp->data);
-              file = thunar_file_get(other_file, NULL);
-              if (file != NULL && THUNAR_IS_FILE (file))
+              if (other_file != NULL)
                 {
-                  thunar_file_reload (file);
-
-                  /* if source and target folders are different, also tell
-                     the target folder to reload for the changes */
-                  if (thunar_file_has_parent (file))
+                  file = thunar_file_get(other_file, NULL);
+                  if (file != NULL && THUNAR_IS_FILE (file))
                     {
-                      other_parent = thunar_file_get_parent (file, NULL);
-                      if (other_parent &&
-                          !g_file_equal (thunar_file_get_file(folder->corresponding_file),
-                                         thunar_file_get_file(other_parent)))
+                      thunar_file_reload (file);
+
+                      /* if source and target folders are different, also tell
+                         the target folder to reload for the changes */
+                      if (thunar_file_has_parent (file))
                         {
-                          thunar_file_reload (other_parent);
-                          g_object_unref (other_parent);
+                          other_parent = thunar_file_get_parent (file, NULL);
+                          if (other_parent &&
+                              !g_file_equal (thunar_file_get_file(folder->corresponding_file),
+                                             thunar_file_get_file(other_parent)))
+                            {
+                              thunar_file_reload (other_parent);
+                              g_object_unref (other_parent);
+                            }
                         }
-                    }
 
-                  /* drop reference on the other file */
-                  g_object_unref (file);
+                      /* drop reference on the other file */
+                      g_object_unref (file);
+                    }
                 }
 
               /* reload the folder of the source file */