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; }