Skip to content

Commit

Permalink
interpreter/interp: check result of external call for #1
Browse files Browse the repository at this point in the history
  • Loading branch information
pdarragh committed Jul 6, 2022
1 parent 9c16d3d commit 7786981
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions interpreter/interp.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@
(let* ([func (hash-ref runtime external-function)]
[sp (hash-ref registers 'rsp)]
[result (func registers memory sp)]
[_ (unless (integer? result)
(raise-user-error 'step
"result of external function '~a' not an integer; got ~v"
external-function
result))]
[_ (unless (<= (integer-length result) (word-size-bits))
(raise-user-error 'step
"integer result of external function '~a' too large; got ~v"
external-function
result))]
[new-registers (hash-set registers 'rax result)])
(make-state #:with-registers new-registers))]
[(Call dst)
Expand Down

0 comments on commit 7786981

Please sign in to comment.