From cc7dedd6b51a01996ddab10fe8b84e30700d1570 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 28 Oct 2011 09:46:45 -0500 Subject: [PATCH] hw/xwin: Fix a memory leak in error path in winInitWM() Signed-off-by: Ryan Pavlik Reviewed-by: Colin Harrison Reviewed-by: Jon TURNEY --- hw/xwin/winmultiwindowwm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 67a58a076..7c4056388 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -1201,11 +1201,13 @@ winInitWM (void **ppWMInfo, XMsgProcArgPtr pXMsgArg = (XMsgProcArgPtr) malloc (sizeof(XMsgProcArgRec)); /* Bail if the input parameters are bad */ - if (pArg == NULL || pWMInfo == NULL) - { - ErrorF ("winInitWM - malloc failed.\n"); - return FALSE; - } + if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) { + ErrorF ("winInitWM - malloc failed.\n"); + free(pArg); + free(pWMInfo); + free(pXMsgArg); + return FALSE; + } /* Zero the allocated memory */ ZeroMemory (pArg, sizeof (WMProcArgRec));