summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
Diffstat (limited to 'src/WorldStorage')
-rw-r--r--src/WorldStorage/FastNBT.cpp2
-rw-r--r--src/WorldStorage/FireworksSerializer.cpp4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp
index f1f092e0b..be25fd1a4 100644
--- a/src/WorldStorage/FastNBT.cpp
+++ b/src/WorldStorage/FastNBT.cpp
@@ -510,7 +510,7 @@ void cFastNBTWriter::AddIntArray(const AString & a_Name, const int * a_Value, si
size_t size = m_Result.length();
if ((cap - size) < (4 + a_NumElements * 4))
{
- m_Result.reserve(size +4 + a_NumElements * 4);
+ m_Result.reserve(size + 4 + (a_NumElements * 4));
}
m_Result.append((const char *)&len, 4);
for (size_t i = 0; i < a_NumElements; i++)
diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp
index bdd5952ad..3c97ae0a2 100644
--- a/src/WorldStorage/FireworksSerializer.cpp
+++ b/src/WorldStorage/FireworksSerializer.cpp
@@ -91,6 +91,8 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
{
// Divide by four as data length returned in bytes
int DataLength = a_NBT.GetDataLength(explosiontag);
+ // round to the next highest multiple of four
+ DataLength -= DataLength % 4;
if (DataLength == 0)
{
continue;
@@ -105,6 +107,8 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
else if (ExplosionName == "FadeColors")
{
int DataLength = a_NBT.GetDataLength(explosiontag) / 4;
+ // round to the next highest multiple of four
+ DataLength -= DataLength % 4;
if (DataLength == 0)
{
continue;