Skip to content

Commit

Permalink
ipc: avoid dereferencing NULL
Browse files Browse the repository at this point in the history
This can happen when ctr->client_api->shutting_down is set to true,
or when there are over 1000 clients with the same name passed to mp_new_client().
  • Loading branch information
1c7718e7 authored and jeeb committed Dec 15, 2017
1 parent cedcdc1 commit 0e311fc
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions input/ipc-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,26 @@ static void *client_thread(void *p)

static void ipc_start_client(struct mp_ipc_ctx *ctx, struct client_arg *client)
{
client->client = mp_new_client(ctx->client_api, client->client_name),
client->log = mp_client_get_log(client->client);
client->client = mp_new_client(ctx->client_api, client->client_name);
if (!client->client)
goto err;

client->log = mp_client_get_log(client->client);

pthread_t client_thr;
if (pthread_create(&client_thr, NULL, client_thread, client)) {
if (pthread_create(&client_thr, NULL, client_thread, client))
goto err;

return;

err:
if (client->client)
mpv_detach_destroy(client->client);
if (client->close_client_fd)
close(client->client_fd);
talloc_free(client);
}

if (client->close_client_fd)
close(client->client_fd);

talloc_free(client);
}

static void ipc_start_client_json(struct mp_ipc_ctx *ctx, int id, int fd)
Expand Down

0 comments on commit 0e311fc

Please sign in to comment.