Author: Whiteknight
Date: Sun Dec 21 06:52:19 2008
New Revision: 34202
Modified:
trunk/config/gen/platform/win32/env.c
Log:
[win32] Take a stab at resolving RT#48276, + a few small upgrades
Modified: trunk/config/gen/platform/win32/env.c
==============================================================================
--- trunk/config/gen/platform/win32/env.c (original)
+++ trunk/config/gen/platform/win32/env.c Sun Dec 21 06:52:19 2008
@@ -54,17 +54,12 @@
const int value_len = strlen(value);
{
- char * const envstring = malloc(
+ char * const envstring = mem_internal_allocate(
name_len /* name */
+ 1 /* '=' */
+ value_len /* value */
+ 1); /* string terminator */
- if (envstring == NULL) {
- /* RT#48276: Shouldn't we tell anyone that we failed? */
- return;
- }
-
/* Save a bit of time, by using the fact we already have the
lengths, avoiding strcat */
strcpy(envstring, name);
@@ -73,11 +68,13 @@
if (_putenv(envstring) == 0) {
/* success */
+ mem_sys_free(envstring);
}
else {
- /* RT#48276: Shouldn't we tell anyone that we failed? */
+ mem_sys_free(envstring);
+ exit_fatal(1, "Unable to set environment variable %s=%s",
+ name, value);
}
- free(envstring);
}
}
}