Fix crash in client with NULL hostname
authorCastor Fu <castor@egocast.org>
Fri, 22 Aug 2014 22:16:44 +0000 (17:16 -0500)
committerJens Axboe <axboe@fb.com>
Fri, 22 Aug 2014 22:16:44 +0000 (17:16 -0500)
Fix this by adding an empty hostname.

Signed-off-by: Jens Axboe <axboe@fb.com>
client.c

index 1f52734370527f6ff0bfcf595234fa0a9b282609..1dded0966cf9bcba261fb1fe5282d20bc3b67c94 100644 (file)
--- a/client.c
+++ b/client.c
@@ -823,9 +823,11 @@ static void convert_gs(struct group_run_stats *dst, struct group_run_stats *src)
 }
 
 static void json_object_add_client_info(struct json_object *obj,
-struct fio_client *client)
+                                       struct fio_client *client)
 {
-       json_object_add_value_string(obj, "hostname", client->hostname);
+       const char *hostname = client->hostname ? client->hostname : "";
+
+       json_object_add_value_string(obj, "hostname", hostname);
        json_object_add_value_int(obj, "port", client->port);
 }