From c16c8b78fadbafcc2e75c581510d17692c718993 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 30 Mar 2025 13:11:29 +0100 Subject: [PATCH] Use osl_getEnvironment instead of getenv Avoids conversion to OUString; and is Unicode-safe on Windows. Change-Id: I39fc7af8822850a187efb108e5f862a9863152fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183506 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- jvmfwk/plugins/sunmajor/pluginlib/util.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx index 21258af12944..1fad8ca13d14 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx @@ -1038,11 +1038,11 @@ void addJavaInfosFromPath( { #if !defined JVM_ONE_PATH_CHECK // Get Java from PATH environment variable - char *szPath= getenv("PATH"); - if(!szPath) + OUString usAllPath; + if (osl_getEnvironment(u"PATH"_ustr.pData, &usAllPath.pData) != osl_Process_E_None + || usAllPath.isEmpty()) return; - OUString usAllPath(szPath, strlen(szPath), osl_getThreadTextEncoding()); sal_Int32 nIndex = 0; do { @@ -1092,10 +1092,10 @@ void addJavaInfoFromJavaHome( // variable. We set it in our build environment for build-time programs, though, // so it is set when running unit tests that involve Java functionality. (Which affects // at least CppunitTest_dbaccess_dialog_save, too, and not only the JunitTest ones.) - char *szJavaHome= getenv("JAVA_HOME"); - if(szJavaHome) + OUString sHome; + if (osl_getEnvironment(u"JAVA_HOME"_ustr.pData, &sHome.pData) == osl_Process_E_None + && !sHome.isEmpty()) { - OUString sHome(szJavaHome, strlen(szJavaHome), osl_getThreadTextEncoding()); OUString sHomeUrl; if(File::getFileURLFromSystemPath(sHome, sHomeUrl) == File::E_None) {