mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-26 13:10:22 +02:00
Improved error checking in bytevector->uint-list and bytevector->sint-list.
Partially fixes <http://bugs.gnu.org/15100>. Reported by Göran Weinholt <goran@weinholt.se>. * libguile/bytevectors.c (INTEGERS_TO_LIST): Make sure SIZE isn't 0. Allow SIZE to be greater than the bytevector length, for consistency with allowing extra bytes at the end when the bytevector length is non-zero. Use scm_from_size_t instead of scm_from_uint. * test-suite/tests/bytevectors.test: Add tests. Remove a test that checks for an exception when SIZE is greater than the bytevector length.
This commit is contained in:
parent
8d5d0425ce
commit
088cfb7d76
2 changed files with 12 additions and 6 deletions
|
@ -155,9 +155,17 @@
|
|||
(let ((b (make-bytevector 0)))
|
||||
(null? (bytevector->uint-list b (endianness big) 2))))
|
||||
|
||||
(pass-if "bytevector->sint-list [length < word size]"
|
||||
(let ((b (make-bytevector 1)))
|
||||
(null? (bytevector->sint-list b (endianness big) 2))))
|
||||
|
||||
(pass-if-exception "bytevector->sint-list [out-of-range]"
|
||||
exception:out-of-range
|
||||
(bytevector->sint-list (make-bytevector 6) (endianness little) 8))
|
||||
(bytevector->sint-list (make-bytevector 6) (endianness little) -1))
|
||||
|
||||
(pass-if-exception "bytevector->uint-list [out-of-range]"
|
||||
exception:out-of-range
|
||||
(bytevector->uint-list (make-bytevector 6) (endianness little) 0))
|
||||
|
||||
(pass-if "bytevector->sint-list [off-by-one]"
|
||||
(equal? (bytevector->sint-list (make-bytevector 31 #xff)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue