mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_resize): get rid of out-of-bound access.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9a4a8673c0
commit
ced2d699b0
2 changed files with 6 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
|||
Tue Jan 25 08:28:19 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_resize): get rid of out-of-bound access.
|
||||
|
||||
Tue Jan 25 07:48:22 2011 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||
|
||||
* test/ruby/test_thread.rb: remove unused variables.
|
||||
|
|
3
string.c
3
string.c
|
@ -1748,7 +1748,8 @@ rb_str_resize(VALUE str, long len)
|
|||
else if (len <= RSTRING_EMBED_LEN_MAX) {
|
||||
char *ptr = RSTRING(str)->as.heap.ptr;
|
||||
STR_SET_EMBED(str);
|
||||
if (slen > 0) MEMCPY(RSTRING(str)->as.ary, ptr, char, len);
|
||||
if (slen > len) slen = len;
|
||||
if (slen > 0) MEMCPY(RSTRING(str)->as.ary, ptr, char, slen);
|
||||
RSTRING(str)->as.ary[len] = '\0';
|
||||
STR_SET_EMBED_LEN(str, len);
|
||||
if (independent) xfree(ptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue