From ec0976f9b0ace946022f48fdb360830985e7ee14 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 00:49:02 +0200 Subject: Fixed a crash when creating negative-size blockareas. Now the server emits a warning instead and continues execution. --- src/BlockArea.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index e3a859e4f..4fe6cd51e 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -309,6 +309,14 @@ void cBlockArea::Clear(void) void cBlockArea::Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes) { + if ((a_SizeX < 0) || (a_SizeY < 0) || (a_SizeZ < 0)) + { + LOGWARNING("Creating a cBlockArea with a negative size! Call to Create ignored. (%d, %d, %d)", + a_SizeX, a_SizeY, a_SizeZ + ); + return; + } + Clear(); int BlockCount = a_SizeX * a_SizeY * a_SizeZ; if ((a_DataTypes & baTypes) != 0) -- cgit v1.2.3