ipc: avoid dereferencing NULL

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().
This commit is contained in:
Martin Shirokov 2017-12-14 17:51:00 +02:00 committed by Jan Ekström
parent cedcdc1f3c
commit 0e311fc0e8
1 changed files with 17 additions and 7 deletions

View File

@ -216,16 +216,26 @@ done:
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)