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
This commit is contained in:
nobu 2015-01-27 04:09:04 +00:00
Родитель 45e23ec16e
Коммит 7e091d24ce
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -36,8 +36,9 @@ bug_str_cstr_term_char(VALUE str)
} }
else { else {
c = rb_enc_mbc_to_codepoint(s, s + len, enc); 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 static VALUE