- Ensure short is correctly cast to int, as we're using it as if it were unsigned
This commit is contained in:
dordsor21 2021-09-22 14:32:49 +01:00
parent a241e594c1
commit 4400b0f83e
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -494,7 +494,7 @@ public final class NBTInputStream implements Closeable {
is.readFully(bytes);
return (bytes);
case NBTConstants.TYPE_STRING:
length = is.readShort();
length = is.readShort() & 0xFFFF;
bytes = new byte[length];
is.readFully(bytes);
return (new String(bytes, NBTConstants.CHARSET));
@ -597,7 +597,7 @@ public final class NBTInputStream implements Closeable {
is.readFully(bytes);
return new ByteArrayTag(bytes);
case NBTConstants.TYPE_STRING:
length = is.readShort();
length = is.readShort() & 0xFFFF;
bytes = new byte[length];
is.readFully(bytes);
return new StringTag(new String(bytes, NBTConstants.CHARSET));