mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
bounds check for parse-stream-debug-info on empty input (fixes issue #826)
This commit is contained in:
parent
899a6bace3
commit
d4eb32f8b1
2 changed files with 14 additions and 10 deletions
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
(test-not (parse parse-nothing ""))
|
(test-not (parse parse-nothing ""))
|
||||||
(test-not (parse parse-nothing "a"))
|
(test-not (parse parse-nothing "a"))
|
||||||
|
(test-error (parse-fully parse-nothing ""))
|
||||||
|
|
||||||
(test-not (parse (parse-char #\a) ""))
|
(test-not (parse (parse-char #\a) ""))
|
||||||
(test-assert (parse-fully (parse-char #\a) "a"))
|
(test-assert (parse-fully (parse-char #\a) "a"))
|
||||||
|
|
|
@ -167,8 +167,11 @@
|
||||||
;; location
|
;; location
|
||||||
(if (%parse-stream-tail s)
|
(if (%parse-stream-tail s)
|
||||||
(parse-stream-debug-info (%parse-stream-tail s) i)
|
(parse-stream-debug-info (%parse-stream-tail s) i)
|
||||||
|
(let ((max-char (parse-stream-max-char s)))
|
||||||
|
(if (< max-char 0)
|
||||||
|
(list 0 0 "")
|
||||||
(let* ((line-info
|
(let* ((line-info
|
||||||
(parse-stream-count-lines s (parse-stream-max-char s)))
|
(parse-stream-count-lines s max-char))
|
||||||
(line (+ (parse-stream-line s) (car line-info)))
|
(line (+ (parse-stream-line s) (car line-info)))
|
||||||
(col (if (zero? (car line-info))
|
(col (if (zero? (car line-info))
|
||||||
(+ (parse-stream-column s) (cadr line-info))
|
(+ (parse-stream-column s) (cadr line-info))
|
||||||
|
@ -176,7 +179,7 @@
|
||||||
(from (car (cddr line-info)))
|
(from (car (cddr line-info)))
|
||||||
(to (parse-stream-end-of-line s (+ from 1)))
|
(to (parse-stream-end-of-line s (+ from 1)))
|
||||||
(str (parse-stream-substring s from s to)))
|
(str (parse-stream-substring s from s to)))
|
||||||
(list line col str))))
|
(list line col str))))))
|
||||||
|
|
||||||
(define (parse-stream-next-source source i)
|
(define (parse-stream-next-source source i)
|
||||||
(if (>= (+ i 1) (vector-length (parse-stream-buffer source)))
|
(if (>= (+ i 1) (vector-length (parse-stream-buffer source)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue