From 8cfa3d861c393b7f2f35eaf30132edd8423ba59a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 5 Aug 2019 10:51:52 +0900 Subject: [PATCH] Do not expect RSTRING_PTR valid after rb_fstring --- load.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/load.c b/load.c index c7f165f697..56dab418da 100644 --- a/load.c +++ b/load.c @@ -1015,7 +1015,7 @@ rb_require_internal(VALUE fname, int safe) RUBY_DTRACE_HOOK(FIND_REQUIRE_RETURN, RSTRING_PTR(fname)); if (found) { - if (!path || !(path = rb_fstring(path), ftptr = load_lock(RSTRING_PTR(path)))) { + if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) { result = 0; } else if (!*ftptr) { @@ -1042,7 +1042,7 @@ rb_require_internal(VALUE fname, int safe) } } EC_POP_TAG(); - load_unlock(ftptr, !state); + if (ftptr) load_unlock(RSTRING_PTR(path), !state); rb_set_safe_level_force(saved.safe); if (state) {