cmp: fix segmentation faults from coerce compiler macro

si::coerce-to-vector assumed that the to be coerced object had the
same length as that specified by the type. This lead to segmentation
faults even in safe code, for example in

(coerce '(a b c) '(vector * 4))

(coerce.error.3 test in ansi-tests)

Actually, si::coerce-to-vector had some checks for a correct length
previously, but they did not work correctly and were removed in commit
baaab01841.
This commit is contained in:
Marius Gerbershagen 2019-12-21 23:03:07 +01:00
parent 00934b358b
commit 7e381828f1

View file

@ -288,10 +288,12 @@
((subtypep type 'sequence)
(multiple-value-bind (elt-type length)
(si::closest-sequence-type type)
(if (eq elt-type 'list)
`(si::coerce-to-list ,value)
`(si::coerce-to-vector ,value ',elt-type ',length
,(and (subtypep type 'simple-array) t)))))
(if (or (eq length '*) (policy-assume-right-type))
(if (eq elt-type 'list)
`(si::coerce-to-list ,value)
`(si::coerce-to-vector ,value ',elt-type ',length
,(and (subtypep type 'simple-array) t)))
form)))
;;
;; There are no other atomic types to optimize
((atom type)