diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx index 8ace85e1e30b..fbd982923499 100644 --- a/cppuhelper/source/servicemanager.cxx +++ b/cppuhelper/source/servicemanager.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -1826,10 +1827,10 @@ void cppuhelper::ServiceManager::preloadImplementations() { OUStringBuffer aMissingMsg; /// Allow external callers & testers to disable certain components - const char *pDisable = getenv("UNODISABLELIBRARY"); - if (pDisable) + if (OUString aDisable; + osl_getEnvironment(u"UNODISABLELIBRARY"_ustr.pData, &aDisable.pData) == osl_Process_E_None + && !aDisable.isEmpty()) { - OUString aDisable(pDisable, strlen(pDisable), RTL_TEXTENCODING_UTF8); for (sal_Int32 i = 0; i >= 0; ) { OUString tok( aDisable.getToken(0, ' ', i) ); diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx index febece5e6040..b7b65831d82f 100644 --- a/framework/source/services/substitutepathvars.cxx +++ b/framework/source/services/substitutepathvars.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -299,13 +300,13 @@ OUString SubstitutePathVariables::GetHomeVariableValue() OUString SubstitutePathVariables::GetPathVariableValue() { OUString aRetStr; - const char* pEnv = getenv( "PATH" ); + OUString aPathList; - if ( pEnv ) + if (osl_getEnvironment(u"PATH"_ustr.pData, &aPathList.pData) == osl_Process_E_None + && !aPathList.isEmpty()) { const int PATH_EXTEND_FACTOR = 200; OUString aTmp; - OUString aPathList( pEnv, strlen( pEnv ), osl_getThreadTextEncoding() ); OUStringBuffer aPathStrBuffer( aPathList.getLength() * PATH_EXTEND_FACTOR / 100 ); bool bAppendSep = false;