From 0124a9ea65118ae70bcc155e2a9a36a6c4869310 Mon Sep 17 00:00:00 2001 From: walter harms Date: Wed, 18 Oct 2017 18:09:05 +0200 Subject: make sure buffer is zero filled and report if allocation failed Signed-off-by: Walter Harms Signed-off-by: Alan Coopersmith --- src/listenwk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/listenwk.c b/src/listenwk.c index 8452e04..6d0f4d6 100644 --- a/src/listenwk.c +++ b/src/listenwk.c @@ -68,11 +68,14 @@ IceListenForWellKnownConnections ( return (0); } - if ((listenObjs = malloc (transCount * sizeof (struct _IceListenObj))) == NULL) + listenObjs = calloc (transCount, sizeof (struct _IceListenObj)); + if (listenObjs == NULL) { for (i = 0; i < transCount; i++) _IceTransClose (transConns[i]); free (transConns); + + strncpy (errorStringRet, "Malloc failed", errorLength); return (0); } -- cgit v1.2.3