Skip to content

Commit

Permalink
Check type of argument before call comparator in sort
Browse files Browse the repository at this point in the history
This fixes CC#1516

>> sort/compare [1 2 #[unset!]] :>
; The R3 process crashes at this point without a system exception
  • Loading branch information
zsx committed Aug 27, 2014
1 parent 750cb0f commit e23ae96
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/t-block.c
Expand Up @@ -387,6 +387,15 @@ static struct {
***********************************************************************/
{
REBVAL *val;

REBVAL *args = BLK_SKIP(VAL_FUNC_ARGS(sort_flags.compare), 1);
if (NOT_END(args) && !TYPE_CHECK(args, VAL_TYPE((REBVAL*)v1))){
Trap3(RE_EXPECT_ARG, Of_Type(sort_flags.compare), args, Of_Type((REBVAL*)v1));
}
++ args;
if (NOT_END(args) && !TYPE_CHECK(args, VAL_TYPE((REBVAL*)v2))) {
Trap3(RE_EXPECT_ARG, Of_Type(sort_flags.compare), args, Of_Type((REBVAL*)v2));
}

if (sort_flags.reverse)
val = Apply_Func(0, sort_flags.compare, v1, v2, 0);
Expand Down

0 comments on commit e23ae96

Please sign in to comment.