diff --git a/file.c b/file.c index e65e548c9a..bf854d4df0 100644 --- a/file.c +++ b/file.c @@ -4035,7 +4035,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na } #endif /* _WIN32 */ -#define EXPAND_PATH_BUFFER() rb_usascii_str_new(0, MAXPATHLEN + 2) +#define EXPAND_PATH_BUFFER() rb_usascii_str_new(0, 1) static VALUE str_shrink(VALUE str) diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 9ca991373e..a4f968be5f 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -874,7 +874,8 @@ class TestFileExhaustive < Test::Unit::TestCase path = File.expand_path("/foo") assert_operator(ObjectSpace.memsize_of(path), :<=, path.bytesize + GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE], bug9934) path = File.expand_path("/a"*25) - assert_equal(path.bytesize + 1 + GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE], ObjectSpace.memsize_of(path), bug9934) + assert_operator(ObjectSpace.memsize_of(path), :<=, + (path.bytesize + 1) * 2 + GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE], bug9934) end def test_expand_path_encoding