Skip to content
Permalink
Browse files

Merge pull request #856 from kachick/segfault-sort

Guard sort with unexpected block from segfault
  • Loading branch information
alex committed Oct 24, 2015
2 parents 4ec45fe + deabda3 commit 4eda63c4e1ed9b25093e41a42b25bd64cd0694a9
Showing with 3 additions and 1 deletion.
  1. +2 −0 tests/objects/test_arrayobject.py
  2. +1 −1 topaz/objects/arrayobject.py
@@ -368,6 +368,8 @@ def test_sort(self, space):
return a.object_id == b.object_id, a, b
""")
assert self.unwrap(space, w_res) == [True, [3, 2, 1], [3, 2, 1]]
with self.raises(space, "NoMethodError"):
space.execute("[0, 1].sort{ |n, m| BasicObject.new }")
with self.raises(space, "ArgumentError", "comparison of Array with Object failed"):
space.execute("[Object.new, []].sort")

@@ -26,7 +26,7 @@ def lt(self, w_a, w_b):
if self.space.is_kind_of(w_cmp_res, self.space.w_bignum):
return self.space.bigint_w(w_cmp_res).lt(rbigint.fromint(0))
else:
return self.space.int_w(w_cmp_res) < 0
return Coerce.bool(self.space, self.space.send(w_cmp_res, "<", [self.space.newint(0)]))


class RubySortBy(BaseRubySortBy):

0 comments on commit 4eda63c

Please sign in to comment.
You can’t perform that action at this time.