diff options
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -3104,7 +3104,7 @@ rb_file_s_basename(int argc, VALUE *argv) } FilePathStringValue(fname); if (RSTRING_LEN(fname) == 0 || !*(name = RSTRING_PTR(fname))) - return fname; + return rb_str_new_shared(fname); name = skipprefix(name); #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC root = name; @@ -3146,7 +3146,7 @@ rb_file_s_basename(int argc, VALUE *argv) if (NIL_P(fext) || !(f = rmext(p, n, StringValueCStr(fext)))) { f = n; } - if (f == RSTRING_LEN(fname)) return fname; + if (f == RSTRING_LEN(fname)) return rb_str_new_shared(fname); } basename = rb_str_new(p, f); rb_enc_copy(basename, fname); |