mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-19 17:49:14 +00:00
UI: Copy result of getenv before use
Another call to getenv, as well as a call to the POSIX functions setenv(), unsetenv(), and putenv() may invalidate the pointer returned by a previous call or modify the string obtained from a previous call. https://en.cppreference.com/w/c/program/getenv
This commit is contained in:
parent
daee83373c
commit
f021da2afa
|
@ -154,13 +154,22 @@ template<typename T> static void SetOBSRef(QListWidgetItem *item, T &&val)
|
|||
|
||||
static void AddExtraModulePaths()
|
||||
{
|
||||
char *plugins_path = getenv("OBS_PLUGINS_PATH");
|
||||
char *plugins_data_path = getenv("OBS_PLUGINS_DATA_PATH");
|
||||
if (plugins_path && plugins_data_path) {
|
||||
string plugins_path, plugins_data_path;
|
||||
char *s;
|
||||
|
||||
s = getenv("OBS_PLUGINS_PATH");
|
||||
if (s)
|
||||
plugins_path = s;
|
||||
|
||||
s = getenv("OBS_PLUGINS_DATA_PATH");
|
||||
if (s)
|
||||
plugins_data_path = s;
|
||||
|
||||
if (!plugins_path.empty() && !plugins_data_path.empty()) {
|
||||
string data_path_with_module_suffix;
|
||||
data_path_with_module_suffix += plugins_data_path;
|
||||
data_path_with_module_suffix += "/%module%";
|
||||
obs_add_module_path(plugins_path,
|
||||
obs_add_module_path(plugins_path.c_str(),
|
||||
data_path_with_module_suffix.c_str());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue