mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_string_value_cstr): make NUL terminated if it is
not done. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2587316c73
commit
92496d73eb
2 changed files with 8 additions and 1 deletions
|
|
@ -1,3 +1,8 @@
|
|||
Wed Apr 14 15:58:11 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_string_value_cstr): make NUL terminated if it is
|
||||
not done.
|
||||
|
||||
Wed Apr 14 12:56:21 2010 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* lib/net/imap (encode_utf7): encode & properly. Thanks, Kengo
|
||||
|
|
|
|||
4
string.c
4
string.c
|
|
@ -1375,10 +1375,12 @@ rb_string_value_cstr(volatile VALUE *ptr)
|
|||
{
|
||||
VALUE str = rb_string_value(ptr);
|
||||
char *s = RSTRING_PTR(str);
|
||||
long len = RSTRING_LEN(str);
|
||||
|
||||
if (!s || RSTRING_LEN(str) != (long)strlen(s)) {
|
||||
if (!s || memchr(s, 0, len)) {
|
||||
rb_raise(rb_eArgError, "string contains null byte");
|
||||
}
|
||||
if (s[len]) rb_str_modify(str);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue