Fix: missing strdup oom check in lttng create.c
[lttng-tools.git] / src / bin / lttng / commands / create.c
index e02b141420c075a1c0e687befade8192eb0d4721..0c318febb900dbe33461a15b823b050298ad90e9 100644 (file)
@@ -324,16 +324,22 @@ static int create_session(void)
                 */
                url = NULL;
        } else if (!opt_no_output) {
+               char *tmp_path;
+
                /* Auto output path */
-               alloc_path = utils_get_home_dir();
-               if (alloc_path == NULL) {
+               tmp_path = utils_get_home_dir();
+               if (tmp_path == NULL) {
                        ERR("HOME path not found.\n \
                                        Please specify an output path using -o, --output PATH");
                        ret = CMD_FATAL;
                        goto error;
                }
-               alloc_path = strdup(alloc_path);
-
+               alloc_path = strdup(tmp_path);
+               if (!alloc_path) {
+                       PERROR("allocating alloc_path");
+                       ret = CMD_FATAL;
+                       goto error;
+               }
                ret = asprintf(&alloc_url,
                                "file://%s/" DEFAULT_TRACE_DIR_NAME "/%s",
                                alloc_path, session_name_date);
This page took 0.024476 seconds and 4 git commands to generate.