diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-02 07:09:16 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-02 07:09:16 +0000 |
commit | 46a33f4648399220521cc5411830ef772792a592 (patch) | |
tree | 0ee70c17ab6346aa9a6ca97a02c2747707403f63 /ext | |
parent | 80bc7bb7a818d49e1ddd54d41a70c68ae3fd0490 (diff) | |
download | ruby-46a33f4648399220521cc5411830ef772792a592.tar.gz |
string.c: fix rb_external_str_new_with_enc
* string.c (rb_external_str_new_with_enc): do not search non-ascii
by NULL pointer. [ruby-core:84055] [Bug #14150]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/-test-/string/new.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ext/-test-/string/new.c b/ext/-test-/string/new.c new file mode 100644 index 0000000000..8a3613e374 --- /dev/null +++ b/ext/-test-/string/new.c @@ -0,0 +1,21 @@ +#include "ruby.h" +#include "ruby/encoding.h" + +VALUE +bug_str_buf_new(VALUE self, VALUE len) +{ + return rb_str_buf_new(NUM2LONG(len)); +} + +VALUE +bug_external_str_new(VALUE self, VALUE len, VALUE enc) +{ + return rb_external_str_new_with_enc(NULL, NUM2LONG(len), rb_to_encoding(enc)); +} + +void +Init_new(VALUE klass) +{ + rb_define_singleton_method(klass, "buf_new", bug_str_buf_new, 1); + rb_define_singleton_method(klass, "external_new", bug_external_str_new, 2); +} |