Issue #5841 has been reported by Benoit Daloze.

----------------------------------------
Bug #5841: Inccorect calculation in rb_file_join
https://bugs.ruby-lang.org/issues/5841

Author: Benoit Daloze
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev


Not really a bug, since the len is only an advice, and sep's len is usually 1 (separator's len), but the logic is not clear:

diff --git a/file.c b/file.c
index fb62c51..15d594a 100644
--- a/file.c
+++ b/file.c
@@ -3825,7 +3825,7 @@ rb_file_join(VALUE ary, VALUE sep)
     }
     if (!NIL_P(sep)) {
        StringValue(sep);
-       len += RSTRING_LEN(sep) * RARRAY_LEN(ary) - 1;
+       len += RSTRING_LEN(sep) * (RARRAY_LEN(ary) - 1);
     }
     result = rb_str_buf_new(len);
     OBJ_INFECT(result, ary);


-- 
http://redmine.ruby-lang.org