From c2ac1f3fd8db7dcada2148d93d56d37254acd412 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Mon, 20 Jun 2016 14:30:48 +0300 Subject: [PATCH] Add a small check to prevent forwarding event if we failed to create the buffer instance. --- source/CoreEvents.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/CoreEvents.cpp b/source/CoreEvents.cpp index 7e347a0c..99d4ead0 100644 --- a/source/CoreEvents.cpp +++ b/source/CoreEvents.cpp @@ -1066,7 +1066,12 @@ void Core::EmitClientScriptData(Int32 player_id, const uint8_t * data, size_t si // Replicate the data to the allocated buffer b.Write(0, reinterpret_cast< Buffer::ConstPtr >(data), size); // Wrap the buffer into a script object - Object o = MakeObject(m_VM, BufferWrapper(std::move(b))); + const Object o = MakeObject(m_VM, BufferWrapper(std::move(b))); + // Wrap the buffer into a script object + if (o.IsNull()) + { + STHROWF("Unable to transform script data into buffer"); + } // Forward the event call PlayerInst & _player = m_Players.at(player_id); Emit(_player.mOnClientScriptData, o, size);