diff options
Diffstat (limited to '')
-rw-r--r-- | src/Items/ItemHandler.cpp | 2 | ||||
-rw-r--r-- | src/UI/Window.cpp | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index a2fd4e3f8..0f56b2b90 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -63,7 +63,7 @@ cItemHandler * cItemHandler::m_ItemHandler[2268]; cItemHandler * cItemHandler::GetItemHandler(int a_ItemType) { - if (a_ItemType < 0) + if ((a_ItemType < 0) || (a_ItemType >= ARRAYCOUNT(m_ItemHandler)) || (!IsValidBlock(a_ItemType) && !IsValidItem(a_ItemType))) { // Either nothing (-1), or bad value, both cases should return the air handler if (a_ItemType < -1) diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 98a9a0cec..af3e3e45c 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -170,7 +170,13 @@ void cWindow::Clicked( const cItem & a_ClickedItem ) { - cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); + if (!IsValidItem(a_ClickedItem.m_ItemType) && !IsValidBlock(a_ClickedItem.m_ItemType)) + { + LOGWARNING("%s: Player \"%s\" clicked to a non-existing item; ignoring click.", __FUNCTION__, a_Player.GetName().c_str()); + return; + } + + cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); if (a_WindowID != m_WindowID) { LOGWARNING("%s: Wrong window ID (exp %d, got %d) received from \"%s\"; ignoring click.", __FUNCTION__, m_WindowID, a_WindowID, a_Player.GetName().c_str()); |