From 59e63f5818531c9509f42e5d582624614275486d Mon Sep 17 00:00:00 2001 From: Jamie Newbon Date: Fri, 10 Jul 2020 13:30:30 +0100 Subject: [PATCH] #6716 Added try catch around memory allocation --- src/lib/synergy/ProtocolUtil.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/synergy/ProtocolUtil.cpp b/src/lib/synergy/ProtocolUtil.cpp index d9f5dc324..ae37ff576 100644 --- a/src/lib/synergy/ProtocolUtil.cpp +++ b/src/lib/synergy/ProtocolUtil.cpp @@ -216,7 +216,15 @@ ProtocolUtil::vreadf(synergy::IStream* stream, const char* fmt, va_list args) // allocate a buffer to read the data UInt8* sBuffer = buffer; if (!useFixed) { - sBuffer = new UInt8[len]; + try{ + sBuffer = new UInt8[len]; + } + catch (std::bad_alloc & exception) { + // Added try catch due to GHSA-chfm-333q-gfpp + LOG((CLOG_ERR "ALLOC: Unable to allocate memory %d bytes", len)); + LOG((CLOG_DEBUG "bad_alloc detected: %s", exception.what())); + throw; + } } // read the data