Skip to content
Snippets Groups Projects
Commit 3be4fc21 authored by Raymond Toy's avatar Raymond Toy
Browse files

Fix ticket:67

Check that the start and end indices make sense for the given
strings.  This is important before we start bashing random parts of
the string, potentially overwriting other objects.
parent cdf11377
No related branches found
No related tags found
No related merge requests found
...@@ -240,22 +240,34 @@ ...@@ -240,22 +240,34 @@
(deftransform replace ((string1 string2 &key (start1 0) (start2 0) (deftransform replace ((string1 string2 &key (start1 0) (start2 0)
end1 end2) end1 end2)
(simple-string simple-string &rest t)) (simple-string simple-string &rest t))
'(locally (declare (optimize (safety 0))) '(progn
(bit-bash-copy string2 ;; Make sure the indices make sense before we go bashing bits
(the vm::offset ;; around!
(+ (the vm::offset (* start2 vm:char-bits)) (assert (<= 0 start1))
vector-data-bit-offset)) (assert (<= start1 (or end1 (length string1))))
string1 (assert (<= (or end1 (length string1)) (length string1)))
(the vm::offset
(+ (the vm::offset (* start1 vm:char-bits)) (assert (<= 0 start2))
vector-data-bit-offset)) (assert (<= start2 (or end2 (length string2))))
(the vm::offset (assert (<= (or end2 (length string2)) (length string2)))
(* (min (the vm::offset (- (or end1 (length string1))
start1)) (locally
(the vm::offset (- (or end2 (length string2)) (declare (optimize (safety 0)))
start2))) (bit-bash-copy string2
vm:char-bits))) (the vm::offset
string1)) (+ (the vm::offset (* start2 vm:char-bits))
vector-data-bit-offset))
string1
(the vm::offset
(+ (the vm::offset (* start1 vm:char-bits))
vector-data-bit-offset))
(the vm::offset
(* (min (the vm::offset (- (or end1 (length string1))
start1))
(the vm::offset (- (or end2 (length string2))
start2)))
vm:char-bits)))
string1)))
;; The original version of this deftransform seemed to cause the ;; The original version of this deftransform seemed to cause the
;; compiler to spend huge amounts of time deriving the type of the ;; compiler to spend huge amounts of time deriving the type of the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment