From f23e554f68027fe7786f0c8e865f48ff45692c5c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 25 Jan 2026 19:40:19 +0900 Subject: [PATCH] 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. --- file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/file.c b/file.c index 112d9b3e4d090c..8f4e9d86c8241c 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));