diff options
author | Andy Wingo <wingo@pobox.com> | 2009-07-24 12:06:40 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2009-07-24 12:06:40 +0200 |
commit | 74deff3c431245b282903d46eb7e571ace8759f3 (patch) | |
tree | 10657f9eab6b3b976af769b0701e4618135c04d5 | |
parent | d95eb7f49f721306ffeb0020724093929cb0e206 (diff) | |
download | guile-74deff3c431245b282903d46eb7e571ace8759f3.tar.gz |
check that jumps are within the range of a signed 16-bit int
* module/language/assembly/compile-bytecode.scm (write-bytecode): Check
that the offset is within the range of a signed int16 value.
-rw-r--r-- | module/language/assembly/compile-bytecode.scm | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/module/language/assembly/compile-bytecode.scm b/module/language/assembly/compile-bytecode.scm index d17e00f2f..80dee833a 100644 --- a/module/language/assembly/compile-bytecode.scm +++ b/module/language/assembly/compile-bytecode.scm @@ -77,7 +77,10 @@ ;; Ew! (for-each write-byte (bytevector->u8-list bv))) (define (write-break label) - (write-uint16-be (- (assq-ref labels label) (+ (get-addr) 2)))) + (let ((offset (- (assq-ref labels label) (+ (get-addr) 2)))) + (cond ((>= offset (ash 1 15)) (error "jump too big" offset)) + ((< offset (- (ash 1 15))) (error "reverse jump too big" offset)) + (else (write-uint16-be offset))))) (let ((inst (car asm)) (args (cdr asm)) |