1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 22:10:21 +02:00

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.
This commit is contained in:
Andy Wingo 2009-07-24 12:06:40 +02:00
parent d95eb7f49f
commit 74deff3c43

View file

@ -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))