Bug fix: Seg fault in copy/move dialog
authorColin Clark <cclark@mcb.net>
Wed, 22 Mar 2017 14:33:48 +0000 (14:33 +0000)
committerColin Clark <cclark@mcb.net>
Wed, 22 Mar 2017 14:33:48 +0000 (14:33 +0000)
If a non-existant folder is entered as the destination in a copy/move
operation, Geeqie will crash.

Check for NULL returned from registered_extension_from_path()

src/ui_fileops.c

index 714efc8..c614e96 100644 (file)
@@ -757,8 +757,13 @@ gboolean file_extension_match(const gchar *path, const gchar *ext)
 
 gchar *remove_extension_from_path(const gchar *path)
 {
+       const gchar *reg_ext;
+
        if (!path) return NULL;
-       return g_strndup(path, strlen(path)-strlen(registered_extension_from_path(path)));
+
+       reg_ext = registered_extension_from_path(path);
+
+       return g_strndup(path, strlen(path) - (reg_ext == NULL ? 0 : strlen(reg_ext)));
 }
 
 void parse_out_relatives(gchar *path)