Fix #741: Crash when creating new dir with same name as already existing file
authorColin Clark <cclark@carbon>
Sun, 2 Feb 2020 12:31:53 +0000 (12:31 +0000)
committerColin Clark <cclark@carbon>
Sun, 2 Feb 2020 12:31:53 +0000 (12:31 +0000)
https://github.com/BestImageViewer/geeqie/issues/741

Check if destination exists before executing command

src/utilops.c

index 1614a40..f1824c9 100644 (file)
@@ -787,14 +787,21 @@ static void file_util_perform_ci_dir(UtilityData *ud, gboolean internal, gboolea
                        GList *work;
                        g_assert(ud->dir_fd->sidecar_files == NULL); // directories should not have sidecars
 
-                       if ((internal && file_data_sc_perform_ci(ud->dir_fd)) ||
-                           (!internal && ext_result))
+                       if (isdir(ud->dest_path))
                                {
-                               file_data_sc_apply_ci(ud->dir_fd);
+                               fail = file_data_ref(ud->dir_fd);
                                }
                        else
                                {
-                               fail = file_data_ref(ud->dir_fd);
+                               if ((internal && file_data_sc_perform_ci(ud->dir_fd)) ||
+                                   (!internal && ext_result))
+                                       {
+                                       file_data_sc_apply_ci(ud->dir_fd);
+                                       }
+                               else
+                                       {
+                                       fail = file_data_ref(ud->dir_fd);
+                                       }
                                }