ruby-changes:65399
From: Yusuke <ko1@a...>
Date: Sat, 6 Mar 2021 00:50:22 +0900 (JST)
Subject: [ruby-changes:65399] 8ccc12118e (master): Keep libpath length non-negative [Bug #16784]
https://git.ruby-lang.org/ruby.git/commit/?id=8ccc12118e From 8ccc12118ea5257f846476088eb9c64944560892 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Sat, 6 Mar 2021 00:45:56 +0900 Subject: 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@g...> --- ruby.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) https://github.com/ruby/ruby/blob/trunk/ruby.c#L671 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 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/