mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
Fixing potential stack corruption in n-ary numeric inequalities.
This commit is contained in:
parent
bbd8827bb2
commit
4495d00bf9
2 changed files with 4 additions and 0 deletions
|
@ -611,6 +611,7 @@
|
||||||
(test #f (<= 1 2 1))
|
(test #f (<= 1 2 1))
|
||||||
(test #t (>= 2 1 1))
|
(test #t (>= 2 1 1))
|
||||||
(test #f (>= 1 2 1))
|
(test #f (>= 1 2 1))
|
||||||
|
(test '(#t #f) (list (<= 1 1 2) (<= 2 1 3)))
|
||||||
|
|
||||||
;; From R7RS 6.2.6 Numerical operations:
|
;; From R7RS 6.2.6 Numerical operations:
|
||||||
;;
|
;;
|
||||||
|
|
3
vm.c
3
vm.c
|
@ -359,6 +359,8 @@ static void generate_opcode_app (sexp ctx, sexp app) {
|
||||||
sexp_emit(ctx, sexp_opcode_code(op));
|
sexp_emit(ctx, sexp_opcode_code(op));
|
||||||
break;
|
break;
|
||||||
case SEXP_OPC_ARITHMETIC_CMP:
|
case SEXP_OPC_ARITHMETIC_CMP:
|
||||||
|
/* With [<true-value>, x] on the stack, and x boolean, */
|
||||||
|
/* AND is equivalent to ROT+DROP. Note one AND for every STACK_REF. */
|
||||||
if (num_args > 2) {
|
if (num_args > 2) {
|
||||||
sexp_emit(ctx, SEXP_OP_STACK_REF);
|
sexp_emit(ctx, SEXP_OP_STACK_REF);
|
||||||
sexp_emit_word(ctx, 2);
|
sexp_emit_word(ctx, 2);
|
||||||
|
@ -375,6 +377,7 @@ static void generate_opcode_app (sexp ctx, sexp app) {
|
||||||
sexp_emit(ctx, SEXP_OP_AND);
|
sexp_emit(ctx, SEXP_OP_AND);
|
||||||
sexp_emit(ctx, SEXP_OP_AND);
|
sexp_emit(ctx, SEXP_OP_AND);
|
||||||
}
|
}
|
||||||
|
sexp_emit(ctx, SEXP_OP_AND);
|
||||||
} else
|
} else
|
||||||
sexp_emit(ctx, sexp_opcode_code(op));
|
sexp_emit(ctx, sexp_opcode_code(op));
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue