From 823868f767d834fce432cd957cff905907d2e4c6 Mon Sep 17 00:00:00 2001 From: Andrew Nelless Date: Fri, 12 May 2017 01:07:57 +0100 Subject: [PATCH] #6037 Fix potential memory leak if SetClipboardData fails --- src/lib/platform/MSWindowsClipboard.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/platform/MSWindowsClipboard.cpp b/src/lib/platform/MSWindowsClipboard.cpp index 2373d255..5a807a0c 100644 --- a/src/lib/platform/MSWindowsClipboard.cpp +++ b/src/lib/platform/MSWindowsClipboard.cpp @@ -88,7 +88,11 @@ MSWindowsClipboard::empty() // mark clipboard as being owned by synergy HGLOBAL data = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, 1); - SetClipboardData(getOwnershipFormat(), data); + if (NULL == SetClipboardData(getOwnershipFormat(), data)) { + LOG((CLOG_DEBUG "failed to set clipboard data")); + GlobalFree(data); + return false; + } return true; }