From f4377085a219f7ca2564091c15243e5d5dcf7960 Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Wed, 26 Sep 2018 20:34:25 +0900 Subject: [PATCH] transcode.c: add GC guard on raise * transcode.c (econv_s_search_convpath): add GC guard to fix SEGV on raise. [Bug #15162] [ruby-core:89172] --- transcode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/transcode.c b/transcode.c index 375346a30d..5bcee00359 100644 --- a/transcode.c +++ b/transcode.c @@ -3155,8 +3155,12 @@ econv_s_search_convpath(int argc, VALUE *argv, VALUE klass) convpath = Qnil; transcode_search_path(sname, dname, search_convpath_i, &convpath); - if (NIL_P(convpath)) - rb_exc_raise(rb_econv_open_exc(sname, dname, ecflags)); + if (NIL_P(convpath)) { + VALUE exc = rb_econv_open_exc(sname, dname, ecflags); + RB_GC_GUARD(snamev); + RB_GC_GUARD(dnamev); + rb_exc_raise(exc); + } if (decorate_convpath(convpath, ecflags) == -1) { VALUE exc = rb_econv_open_exc(sname, dname, ecflags); -- 2.13.3