summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2026-01-25 19:40:19 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2026-01-25 20:05:55 +0900
commitf23e554f68027fe7786f0c8e865f48ff45692c5c (patch)
tree634e96edd93e5db414304297136ff478991f0f06
parent8f9aade9be6f213871357b46b410789bf78e7ac7 (diff)
Fix missing `return`
And align the condition with `enc_find_basename` to remove the code path that `*baselen` potentially can be unset in that function.
-rw-r--r--file.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/file.c b/file.c
index 112d9b3e4d..8f4e9d86c8 100644
--- a/file.c
+++ b/file.c
@@ -5037,8 +5037,8 @@ rb_file_s_basename(int argc, VALUE *argv, VALUE _)
}
n = RSTRING_LEN(fname);
- if (n == 0 || !*name) {
- rb_enc_str_new(0, 0, enc);
+ if (n <= 0 || !*name) {
+ return rb_enc_str_new(0, 0, enc);
}
bool mb_enc = !rb_str_encindex_fastpath(rb_enc_to_index(enc));