From 2318ace3340009c44e78eab094f159f0e0b4a197 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 24 Mar 2019 14:36:10 -0700 Subject: IceOpenConnection: check for malloc failure on connect_to_you too Fixes: https://gitlab.freedesktop.org/xorg/lib/libice/issues/4 Reported-by: mahendra Signed-off-by: Alan Coopersmith --- src/connect.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/connect.c b/src/connect.c index 1554ad6..821b727 100644 --- a/src/connect.c +++ b/src/connect.c @@ -236,6 +236,15 @@ IceOpenConnection ( iceConn->ping_waits = NULL; iceConn->connect_to_you = malloc (sizeof (_IceConnectToYouInfo)); + if (iceConn->connect_to_you == NULL) + { + _IceFreeConnection (iceConn); + if (errorStringRet && errorLength > 0) { + strncpy (errorStringRet, "Can't malloc", errorLength); + errorStringRet[errorLength - 1] = '\0'; + } + return (NULL); + } iceConn->connect_to_you->auth_active = 0; /* -- cgit v1.2.3