GET-EXTERNAL-FORMAT returns NIL for non-symbol XF designators

Fixes lp#2042600
This commit is contained in:
Christophe Rhodes 2023-11-03 09:33:15 +00:00
parent 74db98869a
commit a83158c334
2 changed files with 11 additions and 0 deletions

View file

@ -470,6 +470,8 @@ STRING (or the subsequence bounded by START and END)."
(defun get-external-format (external-format) (defun get-external-format (external-format)
(let* ((external-format (ensure-list external-format)) (let* ((external-format (ensure-list external-format))
(options (cdr external-format))) (options (cdr external-format)))
(unless (symbolp (car external-format))
(return-from get-external-format nil))
(loop for (option value) on options by 'cddr (loop for (option value) on options by 'cddr
unless (or (eql option :newline) (eql option :replacement)) unless (or (eql option :newline) (eql option :replacement))
do (return-from get-external-format nil)) do (return-from get-external-format nil))

View file

@ -428,3 +428,12 @@
(assert (string= b1 b2)) (assert (string= b1 b2))
;; COMPILE-FILE-POSITION is insensitive to file encoding. ;; COMPILE-FILE-POSITION is insensitive to file encoding.
(assert (string= c1 c2)))))) (assert (string= c1 c2))))))
(with-test (:name (:compile-constant-bad-external-format :octets-to-string))
(checked-compile-and-assert ()
'(lambda (x) (sb-ext:octets-to-string x :external-format 0))
(((make-array 0 :element-type '(unsigned-byte 8))) (condition 'error))))
(with-test (:name (:compile-constant-bad-external-format :string-to-octets))
(checked-compile-and-assert ()
'(lambda (x) (sb-ext:octets-to-string x :external-format 0))
(("foo") (condition 'error))))