From 99dd44ec3be5e1e17dbff5ce52a1abe80be46c97 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 30 May 2020 15:09:00 -0700 Subject: [PATCH] client: Fix another memory leak in an error path Duplicate the hostname after if (...) goto err instead of before that check. This was found by inspecting get_new_client() callers. It is not clear to me why Coverity did not complain about this function. Signed-off-by: Bart Van Assche --- client.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client.c b/client.c index 7e5ac17d..a3554638 100644 --- a/client.c +++ b/client.c @@ -390,8 +390,6 @@ struct fio_client *fio_client_add_explicit(struct client_ops *ops, client = get_new_client(); - client->hostname = strdup(hostname); - if (type == Fio_client_socket) client->is_sock = true; else { @@ -410,6 +408,7 @@ struct fio_client *fio_client_add_explicit(struct client_ops *ops, client->ops = ops; client->refs = 1; client->type = ops->client_type; + client->hostname = strdup(hostname); __fio_client_add_cmd_option(client, "fio"); -- 2.25.1