make sure buffer is zero filled and report if allocation failed Signed-off-by: Walter Harms <wha...@bfs.de>
--- src/listenwk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/listenwk.c b/src/listenwk.c index 7517ea8..bc1da76 100644 --- a/src/listenwk.c +++ b/src/listenwk.c @@ -64,11 +64,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); } -- 2.1.4 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel