From e08195b8e7b501010fbed20bb45363d38bb7e338 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Wed, 22 Mar 2017 14:33:48 +0000 Subject: [PATCH] Bug fix: Seg fault in copy/move dialog 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ui_fileops.c b/src/ui_fileops.c index 714efc89..c614e967 100644 --- a/src/ui_fileops.c +++ b/src/ui_fileops.c @@ -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) -- 2.20.1