summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/file.c b/file.c
index f89248b521..1f7b207195 100644
--- a/file.c
+++ b/file.c
@@ -3104,7 +3104,7 @@ rb_file_s_extname(VALUE klass, VALUE fname)
if (!p)
p = name;
else
- p++;
+ name = ++p;
e = 0;
while (*p) {
@@ -3134,7 +3134,7 @@ rb_file_s_extname(VALUE klass, VALUE fname)
break;
p = CharNext(p);
}
- if (!e || e+1 == p) /* no dot, or the only dot is first or end? */
+ if (!e || e == name || e+1 == p) /* no dot, or the only dot is first or end? */
return rb_str_new(0, 0);
extname = rb_str_new(e, p - e); /* keep the dot, too! */
rb_enc_copy(extname, fname);