summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-03-10 21:18:53 +0100
committerTycho <work.tycho+git@gmail.com>2014-03-10 21:18:53 +0100
commit98e15a34a416c31d4689836f4f38161f1270513c (patch)
tree1ae50f2ff4748ac22c810f1f631002b223e02c62 /src/WorldStorage
parentFixed test asserts (diff)
downloadcuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar.gz
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar.bz2
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar.lz
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar.xz
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar.zst
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.zip
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;