diff options
author | Matthias Huetsch [mhu] <matthias.huetsch@oracle.com> | 2010-11-25 14:13:43 +0100 |
---|---|---|
committer | Matthias Huetsch [mhu] <matthias.huetsch@oracle.com> | 2010-11-25 14:13:43 +0100 |
commit | b24c11f89613f6d9ed3429e642b0c4bd610efd7e (patch) | |
tree | 55a5a165aff20e922b7ed4181007e4724b99a97e /dmake/sysintf.c | |
parent | 285c96b26992d3e6ef7a91dbdf4366d976f7a4bb (diff) |
#i115784# dmake: fix memory errors uncovered by valgrind and other tools.
Diffstat (limited to 'dmake/sysintf.c')
-rw-r--r-- | dmake/sysintf.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/dmake/sysintf.c b/dmake/sysintf.c index d7b482a3e405..65104114923f 100644 --- a/dmake/sysintf.c +++ b/dmake/sysintf.c @@ -420,7 +420,6 @@ char *ename; } - /* ** Set the value of the environment string ename to value. ** Returns 0 if success, non-zero if failure @@ -430,16 +429,23 @@ Write_env_string(ename, value) char *ename; char *value; { - char* p; - char* envstr = DmStrAdd(ename, value, FALSE); +#if defined(HAVE_SETENV) - p = envstr+strlen(ename); /* Don't change this code, DmStrAdd does not */ - *p++ = '='; /* add the space if *value is 0, it does */ - if( !*value ) *p = '\0'; /* allocate enough memory for one though. */ + return( setenv(ename, value, 1) ); - return( putenv(envstr) ); -} +#else /* !HAVE_SETENV */ + + char* p; + char* envstr = DmStrAdd(ename, value, FALSE); + p = envstr+strlen(ename); /* Don't change this code, DmStrAdd does not */ + *p++ = '='; /* add the space if *value is 0, it does */ + if( !*value ) *p = '\0'; /* allocate enough memory for one though. */ + + return( putenv(envstr) ); /* Possibly leaking 'envstr' */ + +#endif /* !HAVE_SETENV */ +} PUBLIC void |