Skip to content

Commit

Permalink
* array.c (ary_new): new integer overflow check condition.
Browse files Browse the repository at this point in the history
  suggested by TOYOFUKU Chikanobu <nobu_toyofuku at nifty.com> in
  [ruby-dev:34156].

* array.c (rb_ary_initialize): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Apr 14, 2008
1 parent b2dde82 commit 6be7386
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ Mon Apr 14 12:52:25 2008 Nobuyoshi Nakada <[email protected]>

* gc.c (finalizers): removed. [ruby-dev:34349]

Mon Apr 14 11:30:07 2008 Yukihiro Matsumoto <[email protected]>

* array.c (ary_new): new integer overflow check condition.
suggested by TOYOFUKU Chikanobu <nobu_toyofuku at nifty.com> in
[ruby-dev:34156].

* array.c (rb_ary_initialize): ditto.

Mon Apr 14 00:51:40 2008 Yusuke Endoh <[email protected]>

* test/ruby/test_parse.rb: add tests to achieve over 95% test coverage
Expand Down
4 changes: 2 additions & 2 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ary_new(VALUE klass, long len)
if (len < 0) {
rb_raise(rb_eArgError, "negative array size (or size too big)");
}
if (len > 0 && len * (long)sizeof(VALUE) <= len) {
if (len > LONG_MAX / sizeof(VALUE)) {
rb_raise(rb_eArgError, "array size too big");
}
ary = ary_alloc(klass);
Expand Down Expand Up @@ -313,7 +313,7 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
if (len < 0) {
rb_raise(rb_eArgError, "negative array size");
}
if (len > 0 && len * (long)sizeof(VALUE) <= len) {
if (len > LONG_MAX / sizeof(VALUE)) {
rb_raise(rb_eArgError, "array size too big");
}
rb_ary_modify(ary);
Expand Down

0 comments on commit 6be7386

Please sign in to comment.