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 | a1692f7fdf62dc109886d9910b4dcca635dc2e25 (patch) | |
tree | 0ee70c17ab6346aa9a6ca97a02c2747707403f63 /ext/-test-/string | |
parent | f32bf7e67802000d9d097f3008dee0ca980ecc21 (diff) | |
download | ruby-a1692f7fdf62dc109886d9910b4dcca635dc2e25.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/-test-/string')
-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); +} |