client: Fix another memory leak in an error path
authorBart Van Assche <bvanassche@acm.org>
Sat, 30 May 2020 22:09:00 +0000 (15:09 -0700)
committerBart Van Assche <bvanassche@acm.org>
Tue, 9 Jun 2020 14:11:54 +0000 (07:11 -0700)
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 <bvanassche@acm.org>
client.c

index 7e5ac17de8f380e411eb2590610d2e01c0e5f34d..a3554638e67c09758f462e0d090e20e4de9081ca 100644 (file)
--- 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");