Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

SNBT Parsing #24

Open
rybot666 opened this issue Aug 26, 2023 · 1 comment
Open

SNBT Parsing #24

rybot666 opened this issue Aug 26, 2023 · 1 comment

Comments

@rybot666
Copy link

rybot666 commented Aug 26, 2023

It seems like the SNBT parser is very unreliable. Some inputs cause it to hang, and it returns incorrect data for other inputs.

For example, the perfectly valid SNBT {"a":{}} hangs the SNBT parser until it consumes all available Java heap space and throws an OutOfMemoryError, as in the below code:

InputStream is = new ByteArrayInputStream("{\"a\":{}}".getBytes(StandardCharsets.UTF_8));

try (SNBTIO.StringifiedNBTReader reader = new SNBTIO.StringifiedNBTReader(is)) {
    reader.readNextTag("");
} catch (IOException e) {
    // Input is a BAIS so this *should* never fail.
    throw new AssertionError(e);
}
@booleanbyte
Copy link
Contributor

Hi, I think this is an issue with the SNBT reader when reading empty compound, list and string tags.
I have a fix for these that works with this test, as well as a fixing floating number formatting, I've just forgotten to make pull requests for them.
I'll see if I can get a pull request for those together later today.

@booleanbyte booleanbyte mentioned this issue Aug 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants