From ae71322ba14729d3bde016053a3b4baa80de71d1 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sun, 18 Jun 2023 03:17:20 +0200 Subject: [PATCH] lib/nbt: Fix #80 --- src/lib/nbt.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lib/nbt.cpp b/src/lib/nbt.cpp index 76aecbf..acf8ee9 100644 --- a/src/lib/nbt.cpp +++ b/src/lib/nbt.cpp @@ -1311,7 +1311,8 @@ namespace NBT { goto returnError; } contents.push_back(new Tag::Int8Array("", nextArray.value)); - *processedDataSize += (uint64_t) nextArray.value.size(); + // +4 for the header of the array + *processedDataSize += (uint64_t) nextArray.value.size() + 4; } break; } @@ -1370,7 +1371,8 @@ namespace NBT { goto returnError; } contents.push_back(new Tag::Int32Array("", nextArray.value)); - *processedDataSize += (uint64_t) nextArray.value.size() * 4; + // +4 for the header of the array + *processedDataSize += (uint64_t) nextArray.value.size() * 4 + 4; } break; } @@ -1382,7 +1384,8 @@ namespace NBT { goto returnError; } contents.push_back(new Tag::Int64Array("", nextArray.value)); - *processedDataSize += (uint64_t) nextArray.value.size() * 8; + // +4 for the header of the array + *processedDataSize += (uint64_t) nextArray.value.size() * 8 + 4; } break; } @@ -1627,7 +1630,8 @@ namespace NBT { if (nextArray.isError) { return false; } - *processedDataSize += (uint64_t) nextArray.value.size(); + // +4 for the header of the array + *processedDataSize += (uint64_t) nextArray.value.size() + 4; } return true; } @@ -1678,7 +1682,8 @@ namespace NBT { if (nextArray.isError) { return false; } - *processedDataSize += (uint64_t) nextArray.value.size() * 4; + // +4 for the header of the array + *processedDataSize += (uint64_t) nextArray.value.size() * 4 + 4; } return true; } @@ -1688,7 +1693,8 @@ namespace NBT { if (nextArray.isError) { return false; } - *processedDataSize += (uint64_t) nextArray.value.size() * 8; + // +4 for the header of the array + *processedDataSize += (uint64_t) nextArray.value.size() * 8 + 4; } return true; }