Fix: live_viewer_connection_create(): `lttng_live_msg_iter` can be `NULL`
[babeltrace.git] / src / plugins / ctf / lttng-live / viewer-connection.c
index 42ea78c0ad7fd9cca3d4287fff86c91e22960cbd..c7347020f30baf869583f36c7005c4e5e8504df3 100644 (file)
@@ -24,7 +24,7 @@
 #define BT_COMP_LOG_SELF_COMP (viewer_connection->self_comp)
 #define BT_LOG_OUTPUT_LEVEL (viewer_connection->log_level)
 #define BT_LOG_TAG "PLUGIN/SRC.CTF.LTTNG-LIVE/VIEWER"
-#include "plugins/comp-logging.h"
+#include "logging/comp-logging.h"
 
 #include <stdio.h>
 #include <stdint.h>
@@ -1466,18 +1466,23 @@ error:
 BT_HIDDEN
 struct live_viewer_connection *live_viewer_connection_create(
                const char *url, bool in_query,
-               struct lttng_live_msg_iter *lttng_live_msg_iter)
+               struct lttng_live_msg_iter *lttng_live_msg_iter,
+               bt_logging_level log_level)
 {
        struct live_viewer_connection *viewer_connection;
 
        viewer_connection = g_new0(struct live_viewer_connection, 1);
 
-       if (bt_socket_init(lttng_live_msg_iter->log_level) != 0) {
+       if (bt_socket_init(log_level) != 0) {
                goto error;
        }
 
-       viewer_connection->log_level = lttng_live_msg_iter->log_level;
-       viewer_connection->self_comp = lttng_live_msg_iter->self_comp;
+       viewer_connection->log_level = log_level;
+
+       if (lttng_live_msg_iter) {
+               viewer_connection->self_comp = lttng_live_msg_iter->self_comp;
+       }
+
        bt_object_init_shared(&viewer_connection->obj, connection_release);
        viewer_connection->control_sock = BT_INVALID_SOCKET;
        viewer_connection->port = -1;
This page took 0.023202 seconds and 4 git commands to generate.