summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-02 07:09:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-02 07:09:16 +0000
commita1692f7fdf62dc109886d9910b4dcca635dc2e25 (patch)
tree0ee70c17ab6346aa9a6ca97a02c2747707403f63 /string.c
parentf32bf7e67802000d9d097f3008dee0ca980ecc21 (diff)
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 'string.c')
-rw-r--r--string.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/string.c b/string.c
index 806436e327..56b6f641c6 100644
--- a/string.c
+++ b/string.c
@@ -1011,6 +1011,10 @@ rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
VALUE str;
const int eidx = rb_enc_to_index(eenc);
+ if (!ptr) {
+ return rb_tainted_str_new_with_enc(ptr, len, eenc);
+ }
+
/* ASCII-8BIT case, no conversion */
if ((eidx == rb_ascii8bit_encindex()) ||
(eidx == rb_usascii_encindex() && search_nonascii(ptr, ptr + len))) {