From 46197e3be64a73fc9103bd18da49d2582bc10188 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 9 Apr 2013 19:25:19 +0000 Subject: [PATCH] Fixed chunk possibly writing to uninitialized memory git-svn-id: http://mc-server.googlecode.com/svn/trunk@1376 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Chunk.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 0a7b39f12..4feb45dc8 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -831,6 +831,10 @@ bool cChunk::UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE // Is it in this chunk? if ((a_RelX >= 0) && (a_RelX < cChunkDef::Width) && (a_RelZ >= 0) && (a_RelZ < cChunkDef::Width)) { + if (!IsValid()) + { + return false; + } int BlockIdx = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); a_BlockType = GetBlock(BlockIdx); a_BlockMeta = GetMeta(BlockIdx); @@ -879,6 +883,10 @@ bool cChunk::UnboundedRelSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE // Is it in this chunk? if ((a_RelX >= 0) && (a_RelX < cChunkDef::Width) && (a_RelZ >= 0) && (a_RelZ < cChunkDef::Width)) { + if (!IsValid()) + { + return false; + } SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta); return true; } @@ -925,6 +933,10 @@ bool cChunk::UnboundedRelFastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKT // Is it in this chunk? if ((a_RelX >= 0) && (a_RelX < cChunkDef::Width) && (a_RelZ >= 0) && (a_RelZ < cChunkDef::Width)) { + if (!IsValid()) + { + return false; + } FastSetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta); return true; }