SPDX: Mass-update to GPL-2.0-or-later
[exim.git] / src / src / setenv.c
index ceeb8ef1ca67c8be1f6c253066a8c19bc47dbcf8..a5f056aeedc8a69d916956e9ce341ff0830779f0 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (c) Jeremy Harris 2015 - 2016
  * Copyright (c) The Exim Maintainers 2016 */
 /* See the file NOTICE for conditions of use and distribution. */
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 
 /* This module provides (un)setenv routines for those environments
 lacking them in libraries. It is #include'd by OS/os.c-foo files. */
@@ -17,7 +18,7 @@ setenv(const char * name, const char * val, int overwrite)
 uschar * s;
 if (Ustrchr(name, '=')) return -1;
 if (overwrite || !getenv(name))
-  putenv(CS string_copy_malloc(string_sprintf("%s=%s", name, val)));
+  putenv(CS string_copy_perm(string_sprintf("%s=%s", name, val), FALSE));
 return 0;
 }
 
@@ -26,7 +27,6 @@ unsetenv(const char *name)
 {
 size_t len;
 const char * end;
-char ** e;
 extern char ** environ;
 
 if (!name)
@@ -44,7 +44,7 @@ len = end - name;
 /* Find name in environment and move remaining variables down.
 Do not early-out in case there are duplicate names. */
 
-for (e = environ; *e; e++)
+for (char ** e = environ; *e; e++)
   if (strncmp(*e, name, len) == 0 && (*e)[len] == '=')
     {
     char ** sp = e;