From 3bc608a361a01043b226fb9aaebf88f6fd852925 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Wed, 1 Jan 2014 11:04:07 -0800 Subject: [PATCH] XQuartz: Check for allocated memory before using it in AppleWMSetWindowMenu Signed-off-by: Jeremy Huddleston Sequoia --- hw/xquartz/applewm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c index 4409d4bf6..9ff0ff650 100644 --- a/hw/xquartz/applewm.c +++ b/hw/xquartz/applewm.c @@ -378,6 +378,13 @@ ProcAppleWMSetWindowMenu(register ClientPtr client) items = malloc(sizeof(char *) * nitems); shortcuts = malloc(sizeof(char) * nitems); + if (!items || !shortcuts) { + free(items); + free(shortcuts); + + return BadAlloc; + } + max_len = (stuff->length << 2) - sizeof(xAppleWMSetWindowMenuReq); bytes = (char *)&stuff[1];