ruby-changes:34335
From: nobu <ko1@a...>
Date: Fri, 13 Jun 2014 13:44:14 +0900 (JST)
Subject: [ruby-changes:34335] nobu:r46416 (trunk): array.c: fix array size
nobu 2014-06-13 13:43:57 +0900 (Fri, 13 Jun 2014) New Revision: 46416 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46416 Log: array.c: fix array size * array.c (rb_ary_permutation): `p` is the array of size `r`, as commented at permute0(). since `n >= r` here, buffer overflow never happened, just reduce unnecessary allocation though. Modified files: trunk/ChangeLog trunk/array.c Index: array.c =================================================================== --- array.c (revision 46415) +++ array.c (revision 46416) @@ -4858,7 +4858,7 @@ rb_ary_permutation(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/array.c#L4858 } } else { /* this is the general case */ - volatile VALUE t0 = tmpbuf(n,sizeof(long)); + volatile VALUE t0 = tmpbuf(r,sizeof(long)); long *p = (long*)RSTRING_PTR(t0); volatile VALUE t1 = tmpbuf(n,sizeof(char)); char *used = (char*)RSTRING_PTR(t1); Index: ChangeLog =================================================================== --- ChangeLog (revision 46415) +++ ChangeLog (revision 46416) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jun 13 13:42:58 2014 Nobuyoshi Nakada <nobu@r...> + + * array.c (rb_ary_permutation): `p` is the array of size `r`, as + commented at permute0(). since `n >= r` here, buffer overflow + never happened, just reduce unnecessary allocation though. + Thu Jun 12 20:32:28 2014 Nobuyoshi Nakada <nobu@r...> * string.c (rb_str_resize): should consider the capacity instead -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/