[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-windows
Subject: [patch] remove crashes in putenv(): use "" instead of NULL value
From: Jarosław Staniek <js () iidea ! pl>
Date: 2008-05-15 12:21:06
Message-ID: 482C2AB2.4080204 () iidea ! pl
[Download RAW message or body]
For review; remove crashes in putenv(): use "" instead of NULL value (needed
e.g. for unsetenv()).
NULL values caused a crash in strlen() and _putenv_s(), at least on Vista.
Noticed that in the code of knotify4:
unsetenv( "SESSION_MANAGER" );
--
regards / pozdrawiam, Jaroslaw Staniek
Sponsored by OpenOffice Polska (http://www.openoffice.com.pl/en) to work on
Kexi & KOffice (http://www.kexi.pl/en, http://www.koffice.org/kexi)
KDE Libraries for MS Windows (http://windows.kde.org)
["stdlib.patch" (text/plain)]
Index: src/stdlib.c
===================================================================
--- src/stdlib.c (wersja 807999)
+++ src/stdlib.c (kopia robocza)
@@ -55,13 +55,14 @@
if( !s_msvcrtputenv )
return;
- i = strlen(name) + strlen(value) + 2;
+ i = strlen(name) + (value ? strlen(value) : 0) + 2;
a = (char*)malloc(i);
if (!a) return;
strcpy(a, name);
strcat(a, "=");
- strcat(a, value);
+ if (value)
+ strcat(a, value);
s_msvcrtputenv(a);
free(a);
@@ -82,17 +83,18 @@
//SetEnvironmentVariableA(name, value); // unsure if we need it...
#ifdef KDEWIN32_USE_ENV_S
- return _putenv_s(name, value);
+ return _putenv_s(name, value ? value : "");
#else
if (!name) return -1;
- i = strlen(name) + strlen(value) + 2;
+ i = strlen(name) + (value ? strlen(value) : 0) + 2;
a = (char*)malloc(i);
if (!a) return 1;
strcpy(a, name);
strcat(a, "=");
- strcat(a, value);
+ if (value)
+ strcat(a, value);
iRet = putenv(a);
free(a);
@@ -110,7 +112,7 @@
return;
}
- setenv(name, 0, 1);
+ setenv(name, "", 1);
}
KDEWIN32_EXPORT long int random()
_______________________________________________
Kde-windows mailing list
Kde-windows@kde.org
https://mail.kde.org/mailman/listinfo/kde-windows
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic