From 1401578f9218d06ff3f3e4e26436104515cca0f9 Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Wed, 4 Sep 2013 17:01:51 +0200 Subject: [PATCH] Add bounds check to setter --- src/table.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/table.cpp b/src/table.cpp index 44ebb1e..43b9487 100644 --- a/src/table.cpp +++ b/src/table.cpp @@ -50,6 +50,13 @@ int16_t Table::get(int x, int y, int z) const void Table::set(int16_t value, int x, int y, int z) { + if (x < 0 || x >= m_x + || y < 0 || y >= m_y + || z < 0 || z >= m_z) + { + return; + } + data[m_x*m_y*z + m_x*y + x] = value; modified();