From 7dc44c738ee40d3f608c69a38550c77def440210 Mon Sep 17 00:00:00 2001 From: Owen Green Date: Mon, 8 Jun 2020 22:34:24 +0100 Subject: [PATCH] Don't try and send message responses > 8kb --- include/FluidSCWrapper.hpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/FluidSCWrapper.hpp b/include/FluidSCWrapper.hpp index 8323503..80d88ff 100644 --- a/include/FluidSCWrapper.hpp +++ b/include/FluidSCWrapper.hpp @@ -1354,10 +1354,16 @@ class FluidSCWrapper : public impl::FluidSCWrapperBase MessageResult& result) { auto ft = getInterfaceTable(); + if(!x->mNodeAlive) return; + // allocate return values index numArgs = ToFloatArray::allocSize(static_cast(result)); - - if(!x->mNodeAlive) return; + + if(numArgs > 2048) + { + std::cout << "ERROR: Message response too big to send (" << asUnsigned(numArgs) * sizeof(float) << " bytes)." << std::endl; + return; + } float* values = static_cast( ft->fRTAlloc(x->mNode->mWorld, asUnsigned(numArgs) * sizeof(float))); @@ -1389,6 +1395,12 @@ class FluidSCWrapper : public impl::FluidSCWrapperBase std::tie(offsets, numArgs) = ToFloatArray::allocSize(static_cast>(result)); + if(numArgs > 2048) + { + std::cout << "ERROR: Message response too big to send (" << asUnsigned(numArgs) * sizeof(float) << " bytes)." << std::endl; + return; + } + float* values = static_cast( ft->fRTAlloc(x->mNode->mWorld, asUnsigned(numArgs) * sizeof(float)));