From 47fbe9db47ce99fb2cf0d26197d3be6c192d7c4a Mon Sep 17 00:00:00 2001 From: arslee07 Date: Sun, 12 May 2024 12:40:28 +0900 Subject: [PATCH] Fixed loading io::readall is used instead of io::read to read into the buffer properly --- format/nbt/load.ha | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/format/nbt/load.ha b/format/nbt/load.ha index 0e080a0..3ce23df 100644 --- a/format/nbt/load.ha +++ b/format/nbt/load.ha @@ -8,7 +8,7 @@ use strings; use math; fn scan_buf(h: io::handle, buf: const []u8) (void | error) = { - let result = io::read(h, buf)?; + let result = io::readall(h, buf)?; match (result) { case let sz: size => if (sz != len(buf)) @@ -152,6 +152,9 @@ fn scan_type(h: io::handle) (tagtype | error) = { fn scan_string(h: io::handle) (str | error) = { let length = scan_short(h)?: u16; + if (length == 0) { + return ""; + }; let buf: []u8 = alloc([0...], length); scan_buf(h, buf)?; return strings::fromutf8_unsafe(buf); -- 2.45.2