about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-12-02 01:40:59 +0000
committerUlrich Drepper <drepper@redhat.com>2008-12-02 01:40:59 +0000
commit1fa7ae05b99220ac4590781fdf9fad437900275a (patch)
tree21149fb84ba1f324d4d4c9624f3c69d46492012e
parent37a6a271bf72e247047f1e4e9cf457e895d57dce (diff)
downloadglibc-1fa7ae05b99220ac4590781fdf9fad437900275a.tar.gz
glibc-1fa7ae05b99220ac4590781fdf9fad437900275a.tar.xz
glibc-1fa7ae05b99220ac4590781fdf9fad437900275a.zip
* stdlib/setenv.c (unsetenv): Don't search environment if it does
	not exist.
-rw-r--r--ChangeLog5
-rw-r--r--stdlib/setenv.c29
2 files changed, 20 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 0aa3a5756b..8c593a1267 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-12-01  Ulrich Drepper  <drepper@redhat.com>
+
+	* stdlib/setenv.c (unsetenv): Don't search environment if it does
+	not exist.
+
 2008-11-29  Ulrich Drepper  <drepper@redhat.com>
 
 	* login/utmp_file.c (file_writable): New variable.
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;