summaryrefslogtreecommitdiff
path: root/tests/putenv.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:33 +0100
committerJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:33 +0100
commit5f59a34ab747dde8ede7357f3431bf06bd6002fe (patch)
tree056a4477fd870d454d5be5868cddab829a47f4d2 /tests/putenv.c
parent27dae84ed92f1ef0300263091972338d12e78348 (diff)
New upstream version 1.4.2upstream/1.4.2upstream
Diffstat (limited to 'tests/putenv.c')
-rw-r--r--tests/putenv.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/tests/putenv.c b/tests/putenv.c
index c310ebda..a8abede7 100644
--- a/tests/putenv.c
+++ b/tests/putenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2025 Free Software
+/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2026 Free Software
Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
@@ -70,7 +70,6 @@ int
putenv (char *string)
{
const char *name_end = strchr (string, '=');
- char **ep;
if (name_end == NULL)
{
@@ -97,15 +96,14 @@ putenv (char *string)
/* _putenv ("NAME=") unsets NAME, so invoke _putenv ("NAME= ")
to allocate the environ vector and then replace the new
entry with "NAME=". */
- int putenv_result;
char *name_x = malloc (name_end - string + sizeof "= ");
if (!name_x)
return -1;
memcpy (name_x, string, name_end - string + 1);
name_x[name_end - string + 1] = ' ';
name_x[name_end - string + 2] = 0;
- putenv_result = _putenv (name_x);
- for (ep = environ; *ep; ep++)
+ int putenv_result = _putenv (name_x);
+ for (char **ep = environ; *ep; ep++)
if (streq (*ep, name_x))
{
*ep = string;
@@ -125,6 +123,7 @@ putenv (char *string)
return putenv_result;
}
#else
+ char **ep;
for (ep = environ; *ep; ep++)
if (strncmp (*ep, string, name_end - string) == 0
&& (*ep)[name_end - string] == '=')