Use osl_getEnvironment instead of getenv

Avoids conversion to OUString; and is Unicode-safe on Windows.

Change-Id: If4f76f867f988d43ec4dae0a8e09f1390fee42e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183503
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Mike Kaganski
2025-03-30 13:49:46 +02:00
parent c8d2751a90
commit 0166610b95
2 changed files with 8 additions and 6 deletions
+4 -3
View File
@@ -42,6 +42,7 @@
#include <o3tl/safeint.hxx>
#include <osl/file.hxx>
#include <osl/module.hxx>
#include <osl/process.h>
#include <rtl/ref.hxx>
#include <rtl/uri.hxx>
#include <rtl/ustring.hxx>
@@ -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) );