From 32e1604e768e7c6a0c7231d723a94a25d8f050b6 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 16 Jan 2022 00:56:16 -0500 Subject: [PATCH] lib/ipc: heim_sipc_stream_listener 'ct' lifecycle return failure if calloc() fails do not leak 'ct' if called with invalid 'type' Change-Id: I384f80a51c6ec1d0980cce645c41ff3f6006fd3e --- lib/ipc/server.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ipc/server.c b/lib/ipc/server.c index 839a59638..ae6c2f73f 100644 --- a/lib/ipc/server.c +++ b/lib/ipc/server.c @@ -1055,12 +1055,16 @@ heim_sipc_stream_listener(int fd, int type, heim_ipc_callback callback, void *user, heim_sipc *ctx) { - heim_sipc ct = calloc(1, sizeof(*ct)); + heim_sipc ct; struct client *c; if ((type & HEIM_SIPC_TYPE_IPC) && (type & (HEIM_SIPC_TYPE_UINT32|HEIM_SIPC_TYPE_HTTP))) return EINVAL; + ct = calloc(1, sizeof(*ct)); + if (ct == NULL) + return ENOMEM; + switch (type) { case HEIM_SIPC_TYPE_IPC: c = add_new_socket(fd, LISTEN_SOCKET|WAITING_READ|INCLUDE_ERROR_CODE, callback, user); -- 2.11.4.GIT