diff options
author | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-03 03:21:47 +0000 |
---|---|---|
committer | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-03 03:21:47 +0000 |
commit | c032c5bc9acb015dbe2947a39d3d7ce033c934ee (patch) | |
tree | 37938e53a7701789ce775de08e9c89f7bda271be | |
parent | bd2024165c8d9380a75b88607a9c0dfe066aae5f (diff) | |
download | ruby-c032c5bc9acb015dbe2947a39d3d7ce033c934ee.tar.gz |
* array.c (recursive_equal): fix not to make invalid pointers when
self and other are resized to same size in #== of their elements.
[ruby-dev:46373] [Feature #6177]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | array.c | 8 |
2 files changed, 11 insertions, 3 deletions
@@ -1,3 +1,9 @@ +Sat Nov 3 12:18:35 2012 Masaki Matsushita <glass.saga@gmail.com> + + * array.c (recursive_equal): fix not to make invalid pointers when + self and other are resized to same size in #== of their elements. + [ruby-dev:46373] [Feature #6177] + Sat Nov 3 12:06:15 2012 Kouhei Sutou <kou@cozmixng.org> * test/rexml/test_xml_declaration.rb (TestXmlDeclaration#test_*): @@ -3269,18 +3269,20 @@ rb_ary_rassoc(VALUE ary, VALUE value) static VALUE recursive_equal(VALUE ary1, VALUE ary2, int recur) { - long i; + long i, len1; VALUE *p1, *p2; if (recur) return Qtrue; /* Subtle! */ p1 = RARRAY_PTR(ary1); p2 = RARRAY_PTR(ary2); + len1 = RARRAY_LEN(ary1); - for (i = 0; i < RARRAY_LEN(ary1); i++) { + for (i = 0; i < len1; i++) { if (*p1 != *p2) { if (rb_equal(*p1, *p2)) { - if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) + len1 = RARRAY_LEN(ary1); + if (len1 != RARRAY_LEN(ary2) || len1 < i) return Qfalse; p1 = RARRAY_PTR(ary1) + i; p2 = RARRAY_PTR(ary2) + i; |