From be0b374cada281be15565798c14fa5751c32747a Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Sun, 26 Mar 2017 00:28:04 -0700 Subject: [PATCH] Tweak le_set() for clarity in msystem.cpp --- src/core/msystem.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/core/msystem.cpp b/src/core/msystem.cpp index f3dfba3..ae0179d 100644 --- a/src/core/msystem.cpp +++ b/src/core/msystem.cpp @@ -382,7 +382,7 @@ char *env; register int n; /* where a previous definition is */ /* - * seeif youneed to create the environment list + * see if you need to create the environment list */ if (sz_envp == 0){ if ((envp = c2alloc((const char**)envp, &sz_envp)) == NULL){ @@ -404,18 +404,23 @@ char *env; * (if not defined there, don't define it here) */ size_t p_size=0; - if (strchr(env, '=') == NULL){ + if (strchr(env, '=') == NULL) { + + q = getenv(env); + /* is it defined locally? */ - if ((q = getenv(env)) == NULL){ + if (NULL == q) { /* no -- don't define it here */ return(SE_NONE); } - else if ((p = (char*)malloc((unsigned) (p_size = (strlen(env)+strlen(q)+2)))) - == NULL){ + + size_t p_size = strlen(env) + strlen(q) + 2; + + if ((p = (char*)malloc((unsigned)(p_size))) == NULL) { ERMSG("ran out of memory"); return(SE_NOMEM); } - else{ + else { (void) strncpy(p, env, p_size); (void) strncat(p, "=", p_size); (void) strncat(p, q, p_size);