WINPR_API LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge);
WINPR_API DWORD GetEnvironmentVariableEBA(LPCSTR envBlock, LPCSTR lpName, LPSTR lpBuffer, DWORD nSize);
-WINPR_API BOOL SetEnvironmentVariableEBA(LPCSTR envBlock,LPCSTR lpName, LPCSTR lpValue, LPSTR * newEnvBlock);
+WINPR_API BOOL SetEnvironmentVariableEBA(LPSTR * envBlock,LPCSTR lpName, LPCSTR lpValue);
#ifdef __cplusplus
}
return TRUE;
}
-BOOL SetEnvironmentVariableEBA(LPCSTR envBlock,LPCSTR lpName, LPCSTR lpValue, LPSTR * newEnvBlock)
+BOOL SetEnvironmentVariableEBA(LPSTR * envBlock,LPCSTR lpName, LPCSTR lpValue)
{
int length;
char* envstr;
char* newEB;
+
if (!lpName)
return FALSE;
sprintf_s(envstr, length + 1, "%s=%s", lpName, lpValue);
envstr[length] = '\0';
- newEB = MergeEnvironmentStrings(envBlock,envstr);
+ newEB = MergeEnvironmentStrings((LPCSTR)*envBlock,envstr);
free(envstr);
- *newEnvBlock = newEB;
+ if (*envBlock != NULL)
+ free(*envBlock);
+ *envBlock = newEB;
return TRUE;
}
else
sprintf_s(envstr, length + 1, "%s=", lpName);
envstr[length] = '\0';
- newEB = MergeEnvironmentStrings(envBlock,envstr);
+ newEB = MergeEnvironmentStrings((LPCSTR)*envBlock,envstr);
free(envstr);
- *newEnvBlock = newEB;
+ if (*envBlock != NULL)
+ free(*envBlock);
+ *envBlock = newEB;
return TRUE;
}
}
free(p);
- if (SetEnvironmentVariableEBA(lpszEnvironmentBlock,"test","5",&lpszEnvironmentBlockNew) ) {
+ lpszEnvironmentBlockNew = (LPTCH)malloc(1024);
+ memcpy(lpszEnvironmentBlockNew,lpszEnvironmentBlock,56);
+
+ if (SetEnvironmentVariableEBA(&lpszEnvironmentBlockNew,"test","5") ) {
if (GetEnvironmentVariableEBA(lpszEnvironmentBlockNew,"test", test, 1023) ) {
if (strcmp(test,"5") != 0) {
}
}
- free(lpszEnvironmentBlockNew);
+ //free(lpszEnvironmentBlockNew);
- if (SetEnvironmentVariableEBA(lpszEnvironmentBlock,"test",NULL,&lpszEnvironmentBlockNew) ) {
+ if (SetEnvironmentVariableEBA(&lpszEnvironmentBlockNew,"test",NULL) ) {
if (GetEnvironmentVariableEBA(lpszEnvironmentBlockNew,"test", test, 1023) ) {
return -1;