diff options
author | Martin Shirokov <shirokovMartin@gmail.com> | 2017-12-14 17:51:00 +0200 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2017-12-15 12:51:16 +0200 |
commit | 0e311fc0e8658a2c1f60bd57366c854e7fc129bc (patch) | |
tree | f7d6a34472c717e3c6dcb2072779aaa9b7124ecd /input/ipc-unix.c | |
parent | cedcdc1f3cdf0158cb1ae142d5b0d91278f40bf9 (diff) | |
download | mpv-0e311fc0e8658a2c1f60bd57366c854e7fc129bc.tar.bz2 mpv-0e311fc0e8658a2c1f60bd57366c854e7fc129bc.tar.xz |
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().
Diffstat (limited to 'input/ipc-unix.c')
-rw-r--r-- | input/ipc-unix.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/input/ipc-unix.c b/input/ipc-unix.c index c3315d21b5..3b01d477f1 100644 --- a/input/ipc-unix.c +++ b/input/ipc-unix.c @@ -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) |