Fix: Check for NULL hash tables on relay daemon teardown
[lttng-tools.git] / src / bin / lttng-relayd / viewer-stream.c
index 333246afb3f4d312874cca9cfc144e6cc0fdf932..7c59cd05d88ea3797569e87d8d964d67aa61e562 100644 (file)
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
 #define _LGPL_SOURCE
 #include <common/common.h>
 #include <common/index/index.h>
+#include <common/compat/string.h>
 
 #include "lttng-relayd.h"
 #include "viewer-stream.h"
@@ -51,12 +51,12 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
                goto error;
        }
 
-       vstream->path_name = strndup(stream->path_name, LTTNG_VIEWER_PATH_MAX);
+       vstream->path_name = lttng_strndup(stream->path_name, LTTNG_VIEWER_PATH_MAX);
        if (vstream->path_name == NULL) {
                PERROR("relay viewer path_name alloc");
                goto error;
        }
-       vstream->channel_name = strndup(stream->channel_name,
+       vstream->channel_name = lttng_strndup(stream->channel_name,
                        LTTNG_VIEWER_NAME_MAX);
        if (vstream->channel_name == NULL) {
                PERROR("relay viewer channel_name alloc");
@@ -338,6 +338,10 @@ void print_viewer_streams(void)
        struct lttng_ht_iter iter;
        struct relay_viewer_stream *vstream;
 
+       if (!viewer_streams_ht) {
+               return;
+       }
+
        rcu_read_lock();
        cds_lfht_for_each_entry(viewer_streams_ht->ht, &iter.iter, vstream,
                        stream_n.node) {
This page took 0.023378 seconds and 4 git commands to generate.