Skip to content

Commit

Permalink
bug fix: fatal error when reading array of length zero in some packets
Browse files Browse the repository at this point in the history
  • Loading branch information
stackotter committed Apr 9, 2021
1 parent e14d85f commit f46e08e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion DeltaClient/Sources/Data/Datatypes/NBTCompound.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ struct NBTCompound: CustomStringConvertible {

var list = NBTList(type: listType)
if length != 0 {
for _ in 1...length {
for _ in 0..<length {
let elem = try readTag(ofType: listType)
list.append(elem.value!)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ struct TagsPacket: ClientboundPacket {
static let id: Int = 0x5b

init(from packetReader: inout PacketReader) {
for _ in 1...4 {
for _ in 0..<4 {
let length = packetReader.readVarInt()
for _ in 1...length {
for _ in 0..<length {
let tagName = packetReader.readString()
_ = tagName
let count = packetReader.readVarInt()
for _ in 1...count {
for _ in 0..<count {
let entry = packetReader.readVarInt()
_ = entry
}
Expand Down

0 comments on commit f46e08e

Please sign in to comment.