Skip to content

Commit

Permalink
avisynth.cpp: guard $HOME environment variable usage
Browse files Browse the repository at this point in the history
Similarly to LD_LIBRARY_PATH, if HOME isn't set, this
will stop the core from erroring out.

Fixes #419
  • Loading branch information
qyot27 committed Jan 5, 2025
1 parent 1d21468 commit f283c65
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions avs_core/core/avisynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2404,12 +2404,18 @@ ScriptEnvironment::ScriptEnvironment()
// system_avs_plugindir relies on install path, it and user_avs_plugindir_configurable get
// defined in avisynth_conf.h.in when configuring.

std::string user_avs_plugindir = std::getenv("HOME");
std::string user_avs_plugindir_local = std::getenv("HOME");
std::string user_avs_dirname = "/.avisynth";
user_avs_plugindir.append(user_avs_dirname);
if(std::getenv("HOME")) {
std::string user_avs_plugindir = std::getenv("HOME");
std::string user_avs_plugindir_local = std::getenv("HOME");
std::string user_avs_dirname = "/.avisynth";

user_avs_plugindir_local.append("/").append(user_avs_plugindir_configurable);
user_avs_plugindir.append(user_avs_dirname);

user_avs_plugindir_local.append("/").append(user_avs_plugindir_configurable);

plugin_manager->AddAutoloadDir(user_avs_plugindir, false);
plugin_manager->AddAutoloadDir(user_avs_plugindir_local, false);
}

if (std::getenv("LD_LIBRARY_PATH")) {
std::string ldrel_avs_plugindir, ldrel_stor;
Expand All @@ -2423,8 +2429,6 @@ ScriptEnvironment::ScriptEnvironment()
}
}

plugin_manager->AddAutoloadDir(user_avs_plugindir, false);
plugin_manager->AddAutoloadDir(user_avs_plugindir_local, false);
plugin_manager->AddAutoloadDir(system_avs_plugindir, false);
#endif

Expand Down

0 comments on commit f283c65

Please sign in to comment.