Fix: sessiond: ODR violation results in memory corruption
[lttng-tools.git] / src / common / compat / directory-handle.cpp
index ba5c6925c49feb3667f61e60ea0450507e19fe71..904f59e9489af49604bde85195e23d0eefc79bde 100644 (file)
@@ -147,7 +147,7 @@ struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd(
                int dirfd)
 {
        int ret;
-       struct lttng_directory_handle *handle = (lttng_directory_handle *) zmalloc(sizeof(*handle));
+       struct lttng_directory_handle *handle = zmalloc<lttng_directory_handle>();
        struct stat stat_buf;
 
        if (!handle) {
@@ -405,7 +405,7 @@ end:
 static
 struct lttng_directory_handle *_lttng_directory_handle_create(char *path)
 {
-       struct lttng_directory_handle *handle = zmalloc(sizeof(*handle));
+       struct lttng_directory_handle *handle = zmalloc<lttng_directory_handle>();
 
        if (!handle) {
                goto end;
@@ -525,7 +525,7 @@ struct lttng_directory_handle *lttng_directory_handle_create_from_handle(
                                handle_path_len, LTTNG_PATH_MAX);
                goto end;
        }
-       new_path = zmalloc(handle_path_len);
+       new_path = zmalloc<char>(handle_path_len);
        if (!new_path) {
                PERROR("Failed to initialize directory handle");
                goto end;
@@ -1151,6 +1151,7 @@ int lttng_directory_handle_remove_subdirectory_as_user(
        return ret;
 }
 
+namespace {
 struct rmdir_frame {
        ssize_t parent_frame_idx;
        DIR *dir;
@@ -1158,6 +1159,7 @@ struct rmdir_frame {
        /* Size including '\0'. */
        size_t path_size;
 };
+} /* namespace */
 
 static
 void rmdir_frame_fini(void *data)
This page took 0.024449 seconds and 4 git commands to generate.