Fix uninitialized variable when not HAVE_PUTENV

This commit is contained in:
Tatsuya Kinoshita
2016-03-29 01:31:04 +09:00
parent 286aff8a81
commit b5b25b5904

View File

@@ -213,18 +213,17 @@ set_environ(char *var, char *value)
if (var != NULL && value != NULL) if (var != NULL && value != NULL)
setenv(var, value, 1); setenv(var, value, 1);
#else /* not HAVE_SETENV */ #else /* not HAVE_SETENV */
#ifdef HAVE_PUTENV
static Hash_sv *env_hash = NULL; static Hash_sv *env_hash = NULL;
Str tmp = Strnew_m_charp(var, "=", value, NULL); Str tmp = Strnew_m_charp(var, "=", value, NULL);
if (env_hash == NULL) if (env_hash == NULL)
env_hash = newHash_sv(20); env_hash = newHash_sv(20);
putHash_sv(env_hash, var, (void *)tmp->ptr); putHash_sv(env_hash, var, (void *)tmp->ptr);
#ifdef HAVE_PUTENV
putenv(tmp->ptr); putenv(tmp->ptr);
#else /* not HAVE_PUTENV */ #else /* not HAVE_PUTENV */
extern char **environ; extern char **environ;
char **ne; char **ne;
char *p;
int i, l, el; int i, l, el;
char **e, **newenv; char **e, **newenv;
@@ -251,7 +250,7 @@ set_environ(char *var, char *value)
if (newenv == NULL) if (newenv == NULL)
return; return;
for (e = environ, ne = newenv; *e != NULL; *(ne++) = *(e++)) ; for (e = environ, ne = newenv; *e != NULL; *(ne++) = *(e++)) ;
*(ne++) = p; *(ne++) = tmp->ptr;
*ne = NULL; *ne = NULL;
environ = newenv; environ = newenv;
#endif /* not HAVE_PUTENV */ #endif /* not HAVE_PUTENV */