diff options
-rw-r--r-- | eel/eel-vfs-extensions.c | 19 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file-operations.c | 2 |
2 files changed, 16 insertions, 5 deletions
diff --git a/eel/eel-vfs-extensions.c b/eel/eel-vfs-extensions.c index 75322533c..84a38a10c 100644 --- a/eel/eel-vfs-extensions.c +++ b/eel/eel-vfs-extensions.c @@ -106,20 +106,31 @@ char * eel_filename_get_extension_offset (const char *filename) { char *end, *end2; + const char *start; - end = strrchr (filename, '.'); + if (filename == NULL || filename[0] == '\0') { + return NULL; + } - if (end && end != filename) { + /* basename must have at least one char */ + start = filename + 1; + + end = strrchr (start, '.'); + if (end == NULL || end[1] == '\0') { + return NULL; + } + + if (end != start) { if (strcmp (end, ".gz") == 0 || strcmp (end, ".bz2") == 0 || strcmp (end, ".sit") == 0 || strcmp (end, ".Z") == 0) { end2 = end - 1; - while (end2 > filename && + while (end2 > start && *end2 != '.') { end2--; } - if (end2 != filename) { + if (end2 != start) { end = end2; } } diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c index 0bc5b0a60..bbbb26b43 100644 --- a/libnautilus-private/nautilus-file-operations.c +++ b/libnautilus-private/nautilus-file-operations.c @@ -543,7 +543,7 @@ parse_previous_duplicate_name (const char *name, g_assert (name[0] != '\0'); - *suffix = eel_filename_get_extension_offset (name + 1); + *suffix = eel_filename_get_extension_offset (name); if (*suffix == NULL || (*suffix)[1] == '\0') { /* no suffix */ |