зеркало из https://github.com/github/ruby.git
* string.c (rb_str_times): make empty strings to keep taintness,
and a little improvement. [ruby-dev:26900] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
40a77284e5
Коммит
7d41159212
|
@ -1,3 +1,8 @@
|
|||
Fri Sep 9 16:35:04 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_times): make empty strings to keep taintness,
|
||||
and a little improvement. [ruby-dev:26900]
|
||||
|
||||
Thu Sep 8 14:58:11 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* merged a patch from Takahiro Kambe <taca@back-street.net> to
|
||||
|
|
8
string.c
8
string.c
|
@ -412,13 +412,13 @@ rb_str_times(str, times)
|
|||
if (len < 0) {
|
||||
rb_raise(rb_eArgError, "negative argument");
|
||||
}
|
||||
if (LONG_MAX/len < RSTRING(str)->len) {
|
||||
if (len && LONG_MAX/len < RSTRING(str)->len) {
|
||||
rb_raise(rb_eArgError, "argument too big");
|
||||
}
|
||||
|
||||
str2 = rb_str_new5(str,0, RSTRING(str)->len*len);
|
||||
for (i=0; i<len; i++) {
|
||||
memcpy(RSTRING(str2)->ptr+(i*RSTRING(str)->len),
|
||||
str2 = rb_str_new5(str,0, len *= RSTRING(str)->len);
|
||||
for (i = 0; i < len; i += RSTRING(str)->len) {
|
||||
memcpy(RSTRING(str2)->ptr + i,
|
||||
RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
}
|
||||
RSTRING(str2)->ptr[RSTRING(str2)->len] = '\0';
|
||||
|
|
Загрузка…
Ссылка в новой задаче