summaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-01-02 21:14:11 +0000
committerJakub Jelinek <jakub@redhat.com>2009-01-02 21:14:11 +0000
commite3e60f6bdc80109e6cfbd092049a4bbb2f43c457 (patch)
treed166064d5e5bfd7821e133a5c76d8aae50d81766 /stdlib
parent033b8b2d4de5cd8abe4278cd2b30c50d7a78e886 (diff)
Updated to fedora-glibc-20090102T2110cvs/fedora-glibc-2_9_90-1
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/Makefile2
-rw-r--r--stdlib/setenv.c29
-rw-r--r--stdlib/tst-unsetenv1.c12
3 files changed, 28 insertions, 15 deletions
diff --git a/stdlib/Makefile b/stdlib/Makefile
index 1fe7f70177..a69bdaeb73 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -69,7 +69,7 @@ tests := tst-strtol tst-strtod testmb testrand testsort testdiv \
test-a64l tst-qsort tst-system testmb2 bug-strtod2 \
tst-atof1 tst-atof2 tst-strtod2 tst-strtod3 tst-rand48-2 \
tst-makecontext tst-strtod4 tst-strtod5 tst-qsort2 \
- tst-makecontext2 tst-strtod6
+ tst-makecontext2 tst-strtod6 tst-unsetenv1
include ../Makeconfig
diff --git a/stdlib/setenv.c b/stdlib/setenv.c
index 48aaecffe0..fe591b7db8 100644
--- a/stdlib/setenv.c
+++ b/stdlib/setenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,1995-2001,2004 Free Software Foundation, Inc.
+/* Copyright (C) 1992,1995-2001,2004, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -292,19 +292,20 @@ unsetenv (name)
LOCK;
ep = __environ;
- while (*ep != NULL)
- if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
- {
- /* Found it. Remove this pointer by moving later ones back. */
- char **dp = ep;
-
- do
- dp[0] = dp[1];
- while (*dp++);
- /* Continue the loop in case NAME appears again. */
- }
- else
- ++ep;
+ if (ep != NULL)
+ while (*ep != NULL)
+ if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
+ {
+ /* Found it. Remove this pointer by moving later ones back. */
+ char **dp = ep;
+
+ do
+ dp[0] = dp[1];
+ while (*dp++);
+ /* Continue the loop in case NAME appears again. */
+ }
+ else
+ ++ep;
UNLOCK;
diff --git a/stdlib/tst-unsetenv1.c b/stdlib/tst-unsetenv1.c
new file mode 100644
index 0000000000..a2a760d241
--- /dev/null
+++ b/stdlib/tst-unsetenv1.c
@@ -0,0 +1,12 @@
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+ clearenv ();
+ unsetenv ("FOO");
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"