1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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>
This commit is contained in:
Yusuke Endoh 2021-03-06 00:45:56 +09:00
parent 261b746dca
commit 8ccc12118e

5
ruby.c
View file

@ -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