configure: fix check_min_lib_version() eval
[fio.git] / client.c
index 134497cb99c1e5b2dce58a6415106146a7e98661..29d8750a5b2b6948bc8206399d6a1be774a22a78 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");
 
@@ -471,8 +470,10 @@ int fio_client_add(struct client_ops *ops, const char *hostname, void **cookie)
                                        &client->is_sock, &client->port,
                                        &client->addr.sin_addr,
                                        &client->addr6.sin6_addr,
-                                       &client->ipv6))
+                                       &client->ipv6)) {
+               fio_put_client(client);
                return -1;
+       }
 
        client->fd = -1;
        client->ops = ops;
@@ -1141,14 +1142,14 @@ static void handle_job_opt(struct fio_client *client, struct fio_net_cmd *cmd)
 {
        struct cmd_job_option *pdu = (struct cmd_job_option *) cmd->payload;
 
-       if (!job_opt_object)
-               return;
-
        pdu->global = le16_to_cpu(pdu->global);
        pdu->truncated = le16_to_cpu(pdu->truncated);
        pdu->groupid = le32_to_cpu(pdu->groupid);
 
        if (pdu->global) {
+               if (!job_opt_object)
+                       return;
+
                json_object_add_value_string(job_opt_object,
                                             (const char *)pdu->name,
                                             (const char *)pdu->value);