From f283c65d6f01081d6bf7c23f01d00a94531d84e3 Mon Sep 17 00:00:00 2001 From: Stephen Hutchinson Date: Sun, 5 Jan 2025 14:03:46 -0500 Subject: [PATCH] avisynth.cpp: guard $HOME environment variable usage Similarly to LD_LIBRARY_PATH, if HOME isn't set, this will stop the core from erroring out. Fixes #419 --- avs_core/core/avisynth.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/avs_core/core/avisynth.cpp b/avs_core/core/avisynth.cpp index 4536eb199..f4cb816cd 100644 --- a/avs_core/core/avisynth.cpp +++ b/avs_core/core/avisynth.cpp @@ -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; @@ -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