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/branches/ruby_1_8@27337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9089c80d99
commit
09267569c3
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.
|
||||
|
||||
Mon Apr 12 21:47:41 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* LEGAL: separated the section for parse.c. contributed by Paul
|
||||
|
|
4
string.c
4
string.c
|
@ -607,10 +607,12 @@ rb_string_value_cstr(ptr)
|
|||
{
|
||||
VALUE str = rb_string_value(ptr);
|
||||
char *s = RSTRING(str)->ptr;
|
||||
long len = RSTRING(str)->len;
|
||||
|
||||
if (!s || RSTRING(str)->len != 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