summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2019-10-11 17:10:09 -0400
committerDavid Thompson <dthompson2@worcester.edu>2019-10-11 17:10:09 -0400
commitf85d5ba0a00e25bf063b8f9c993c815490bc483a (patch)
treee2dddc789a605e00c45273f153c8e9c46a1940a5
parentc7974d6cf65e55327ca59b1c8f4db3d36729c4a5 (diff)
array-list: Add bounds checking to array-list-ref.
-rw-r--r--chickadee/array-list.scm4
1 files changed, 3 insertions, 1 deletions
diff --git a/chickadee/array-list.scm b/chickadee/array-list.scm
index dad0b8d..54a11e8 100644
--- a/chickadee/array-list.scm
+++ b/chickadee/array-list.scm
@@ -76,7 +76,9 @@
(set-array-list-vector! array-list new-vec)))
(define (array-list-ref array-list i)
- (vector-ref (array-list-vector array-list) i))
+ (if (and (>= i 0) (< i (array-list-size array-list)))
+ (vector-ref (array-list-vector array-list) i)
+ (error "array list index out of bounds" i)))
(define (array-list-set! array-list i x)
(vector-set! (array-list-vector array-list) i x))