diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index d836fb07a..f4e4b004c 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -279,14 +279,15 @@ int Process::start(const std::string &path, if (file && strcmp(file, "syslog")) unsetenv("LIBCAMERA_LOG_FILE"); - const char **argv = new const char *[args.size() + 2]; - unsigned int len = args.size(); + const size_t len = args.size(); + auto argv = std::make_unique(len + 2); + argv[0] = path.c_str(); - for (unsigned int i = 0; i < len; i++) + for (size_t i = 0; i < len; i++) argv[i + 1] = args[i].c_str(); argv[len + 1] = nullptr; - execv(path.c_str(), (char **)argv); + execv(path.c_str(), const_cast(argv.get())); _exit(EXIT_FAILURE); }