ruby-changes:61440
From: Benoit <ko1@a...>
Date: Mon, 1 Jun 2020 07:35:47 +0900 (JST)
Subject: [ruby-changes:61440] b7e1de117e (master): Make sure rb_enc_str_new_static() is used when enc is NULL
https://git.ruby-lang.org/ruby.git/commit/?id=b7e1de117e From b7e1de117e20911ed86b229a4c2f912e469c6472 Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Mon, 1 Jun 2020 00:30:41 +0200 Subject: Make sure rb_enc_str_new_static() is used when enc is NULL * The definition of the rb_enc_str_new_cstr macro depends on HAVE_BUILTIN___BUILTIN_CONSTANT_P. * It SEGV on mswin otherwise. diff --git a/spec/ruby/optional/capi/ext/encoding_spec.c b/spec/ruby/optional/capi/ext/encoding_spec.c index 6e2e7ce..2ee5c9c 100644 --- a/spec/ruby/optional/capi/ext/encoding_spec.c +++ b/spec/ruby/optional/capi/ext/encoding_spec.c @@ -166,8 +166,13 @@ static VALUE encoding_spec_rb_enc_str_new_cstr(VALUE self, VALUE str, VALUE enc) https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/encoding_spec.c#L166 } static VALUE encoding_spec_rb_enc_str_new_cstr_constant(VALUE self, VALUE enc) { - rb_encoding *e = NIL_P(enc) ? NULL : rb_to_encoding(enc); - return rb_enc_str_new_cstr("test string literal", e); + if (NIL_P(enc)) { + rb_encoding *e = NULL; + return rb_enc_str_new_static("test string literal", strlen("test string literal"), e); + } else { + rb_encoding *e = rb_to_encoding(enc); + return rb_enc_str_new_cstr("test string literal", e); + } } static VALUE encoding_spec_rb_enc_str_new(VALUE self, VALUE str, VALUE len, VALUE enc) { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/