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
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user