diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-27 04:09:04 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-27 04:09:04 +0000 |
commit | 7e091d24ce6e478ba92b4c1188be0a795e0fc151 (patch) | |
tree | f04164559fa641ba5061005e4094072d45e41489 /ext/-test- | |
parent | 45e23ec16e0b57745c7ab9fcb166b6511c797ef5 (diff) | |
download | ruby-7e091d24ce6e478ba92b4c1188be0a795e0fc151.tar.gz |
cstr.c: nil iff terminated validly
* ext/-test-/string/cstr.c (bug_str_cstr_term_char): return nil
only when terminated validly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-')
-rw-r--r-- | ext/-test-/string/cstr.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/-test-/string/cstr.c b/ext/-test-/string/cstr.c index 81edbb0b79..ba2e46bc55 100644 --- a/ext/-test-/string/cstr.c +++ b/ext/-test-/string/cstr.c @@ -36,8 +36,9 @@ bug_str_cstr_term_char(VALUE str) } else { c = rb_enc_mbc_to_codepoint(s, s + len, enc); + if (!c) return Qnil; } - return c ? rb_enc_uint_chr((unsigned int)c, enc) : Qnil; + return rb_enc_uint_chr((unsigned int)c, enc); } static VALUE |