summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sal/osl/os2/process_impl.cxx34
1 files changed, 31 insertions, 3 deletions
diff --git a/sal/osl/os2/process_impl.cxx b/sal/osl/os2/process_impl.cxx
index 7e0664995..f689d5bc5 100644
--- a/sal/osl/os2/process_impl.cxx
+++ b/sal/osl/os2/process_impl.cxx
@@ -306,11 +306,26 @@ oslProcessError SAL_CALL osl_setEnvironment(rtl_uString* pustrEnvVar, rtl_uStrin
if (pstr_env_var != 0 && pstr_val != 0)
{
- if (setenv(rtl_string_getStr(pstr_env_var), rtl_string_getStr(pstr_val), 1) == 0)
+ //Can't determine if OS/2 EMX has a working setenv or not, so use putenv,
+ //feel free to use setenv here if its available and works
+ rtl_String * pBuffer = NULL;
+
+ sal_Int32 nCapacity = rtl_stringbuffer_newFromStringBuffer( &pBuffer,
+ rtl_string_getLength(pstr_env_var) + rtl_string_getLength(pstr_val) + 1,
+ pstr_env_var );
+ rtl_stringbuffer_insert( &pBuffer, &nCapacity, pBuffer->length, "=", 1);
+ rtl_stringbuffer_insert( &pBuffer, &nCapacity, pBuffer->length,
+ rtl_string_getStr(pstr_val), rtl_string_getLength(pstr_val) );
+
+ rtl_string_acquire(pBuffer); // argument to putenv must leak on success
+
+ if (putenv(rtl_string_getStr(pBuffer)) == 0)
result = osl_Process_E_None;
+ else
+ rtl_string_release(pBuffer);
}
- if (pstr_val != 0)
+ if (pstr_val)
rtl_string_release(pstr_val);
if (pstr_env_var != 0)
@@ -337,8 +352,21 @@ oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString* pustrEnvVar)
if (pstr_env_var)
{
- if (unsetenv(rtl_string_getStr(pstr_env_var)) == 0)
+ //Can't determine if OS/2 EMX has a working unsetenv or not, so use putenv,
+ //feel free to use unsetenv here if its available and works
+ rtl_String * pBuffer = NULL;
+
+ sal_Int32 nCapacity = rtl_stringbuffer_newFromStringBuffer( &pBuffer,
+ rtl_string_getLength(pstr_env_var) + 1, pstr_env_var );
+ rtl_stringbuffer_insert( &pBuffer, &nCapacity, pBuffer->length, "=", 1);
+
+ rtl_string_acquire(pBuffer); // argument to putenv must leak on success
+
+ if (putenv(rtl_string_getStr(pBuffer)) == 0)
result = osl_Process_E_None;
+ else
+ rtl_string_release(pBuffer);
+
rtl_string_release(pstr_env_var);
}