1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-02 21:12:23 +00:00

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

View File

@ -216,16 +216,26 @@ done:
static void ipc_start_client(struct mp_ipc_ctx *ctx, struct client_arg *client) 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->client = mp_new_client(ctx->client_api, client->client_name);
client->log = mp_client_get_log(client->client); if (!client->client)
goto err;
client->log = mp_client_get_log(client->client);
pthread_t client_thr; 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); mpv_detach_destroy(client->client);
if (client->close_client_fd)
close(client->client_fd); if (client->close_client_fd)
talloc_free(client); close(client->client_fd);
}
talloc_free(client);
} }
static void ipc_start_client_json(struct mp_ipc_ctx *ctx, int id, int fd) static void ipc_start_client_json(struct mp_ipc_ctx *ctx, int id, int fd)