sanitize one of the recent c-string decoding tests
authorNikodemus Siivola <nikodemus@random-state.net>
Thu, 19 Apr 2012 19:37:08 +0000 (22:37 +0300)
committerNikodemus Siivola <nikodemus@random-state.net>
Thu, 19 Apr 2012 19:38:50 +0000 (22:38 +0300)
  No out-of-bounds accesses, thanks!

  ...and thanks to Nathan who spotted my bogosity.

tests/alien.impure.lisp

index aa6eee6..98e88f2 100644 (file)
   (assert
    (eq :multibyte-4
        (handler-case
-           (let ((c-string (coerce #(70 111 246 0)
+           ;; KLUDGE, sort of.
+           ;;
+           ;; C-STRING decoding doesn't know how long the string is, and since this
+           ;; looks like a 4-byte sequence, it will grab 4 octets off the end.
+           ;;
+           ;; So we pad the vector for safety's sake.
+           (let ((c-string (coerce #(70 111 246 0 0 0)
                                    '(vector (unsigned-byte 8)))))
              (sb-sys:with-pinned-objects (c-string)
                (sb-alien::c-string-to-string (sb-sys:vector-sap c-string)