Check for zero-length binary streams

This commit is contained in:
Emery Hemingway 2022-10-29 18:32:38 -05:00
parent 154ffb6cd8
commit 201cb7c68e
1 changed files with 1 additions and 0 deletions

View File

@ -545,6 +545,7 @@ proc encode*[E](pr: Preserve[E]): seq[byte] =
proc decodePreserves*(s: Stream; E = void): Preserve[E] =
## Decode a Preserves value from a binary-encoded stream.
if s.atEnd: raise newException(ValueError, "End of Preserves stream")
proc assertStream(check: bool) =
if not check:
raise newException(ValueError, "invalid Preserves stream")