Have std/json look at args.src.is_closed()

This commit is contained in:
Nigel Tao committed 2020-02-19 14:04:49 +11:00
1 parent 8850d38403
commit 67306567f9
3 files changed
+24 -5

No files matched your search

+9
View File
@@ -103,6 +103,9 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
args.dst.write_fast_token!(value: 0, length: whitespace_length as base.u64)
whitespace_length = 0
}
if args.src.is_closed() {
return "#bad input"
}
yield? base."$short read"
whitespace_length = 0
continue.outer
@@ -169,6 +172,9 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
args.dst.write_fast_token!(value: 0x60_0001, length: string_length as base.u64)
string_length = 0
}
if args.src.is_closed() {
return "#bad input"
}
yield? base."$short read"
string_length = 0
continue.string_loop
@@ -260,6 +266,9 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
} else if number_length < 1 {
return "#unsupported number length"
}
if args.src.is_closed() {
return "#bad input"
}
yield? base."$short read"
while args.dst.available() <= 0,
post args.dst.available() > 0,