summaryrefslogtreecommitdiff
path: root/tests/setenv.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-03-03 19:11:32 +0100
committerJörg Frings-Fürst <debian@jff.email>2024-03-03 19:11:32 +0100
commit00893e79fc62966067af1a106567db96bd170338 (patch)
tree52b35cd0b42ca28e62a2ffbecade2e13dd8332cf /tests/setenv.c
parent26112352a774737e1ce5580c93654a26c1e82b39 (diff)
New upstream version 1.2upstream/1.2upstream
Diffstat (limited to 'tests/setenv.c')
-rw-r--r--tests/setenv.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/setenv.c b/tests/setenv.c
index ebfd4e55..9e2e9e2f 100644
--- a/tests/setenv.c
+++ b/tests/setenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995-2003, 2005-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2003, 2005-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This file is free software: you can redistribute it and/or modify
@@ -82,6 +82,7 @@ typedef int (*compar_fn_t) (const void *, const void *);
static void *known_values;
# define KNOWN_VALUE(Str) \
+ __extension__ \
({ \
void *value = tfind (Str, &known_values, (compar_fn_t) strcmp); \
value != NULL ? *(char **) value : NULL; \
@@ -375,6 +376,11 @@ rpl_setenv (const char *name, const char *value, int replace)
int saved_errno;
size_t len = strlen (value);
tmp = malloca (len + 2);
+ if (tmp == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
/* Since leading '=' is eaten, double it up. */
*tmp = '=';
memcpy (tmp + 1, value, len + 1);