summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2021-03-06 00:45:56 +0900
committerYusuke Endoh <mame@ruby-lang.org>2021-03-06 00:50:09 +0900
commit8ccc12118ea5257f846476088eb9c64944560892 (patch)
tree053f777299134443368dcaee092dfac984b82661 /ruby.c
parent261b746dcaf50ba34748ccff85a94c68879a301c (diff)
Keep libpath length non-negative [Bug #16784]
When runtime_libruby_path does not include '/', it attempts to call rb_str_resize with negative length. This change makes sure that the length non-negative. Co-Authored-By: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ruby.c b/ruby.c
index b94937b..f297c2b 100644
--- a/ruby.c
+++ b/ruby.c
@@ -671,8 +671,11 @@ ruby_init_loadpath(void)
p = p2;
}
#endif
+ baselen = p - libpath;
+ }
+ else {
+ baselen = 0;
}
- baselen = p - libpath;
rb_str_resize(sopath, baselen);
libpath = RSTRING_PTR(sopath);
#define PREFIX_PATH() sopath