From bca9f4abe86e3ba2d84cb5ff96d55fe9d5afc722 Mon Sep 17 00:00:00 2001
From: Ulrich Drepper <drepper@redhat.com>
Date: Mon, 11 Oct 1999 04:34:14 +0000
Subject: [PATCH] Fix typo.

	* stdlib/exit.c (exit): Beware to not free statically allocated
---
 ChangeLog     | 2 +-
 stdlib/exit.c | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 47c6ab4798..4ee3d2d027 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@
 
 	* stdlib/atexit.c (initial): New variable.  Use to initialize
 	__exit_funcs.
-	* stdlib/exit.c (exit): Beware to not free statically allocale
+	* stdlib/exit.c (exit): Beware to not free statically allocated
 	list element [PR libc/1305].
 
 	* stdlib/xpg_basename.c (__xpg_basename): Don't return pointer to
diff --git a/stdlib/exit.c b/stdlib/exit.c
index dc189556b4..f44c519aa7 100644
--- a/stdlib/exit.c
+++ b/stdlib/exit.c
@@ -62,7 +62,10 @@ exit (int status)
 
       old = __exit_funcs;
       __exit_funcs = __exit_funcs->next;
-      free (old);
+      if (__exit_funcs != NULL)
+	/* Don't free the last element in the chain, this is the statically
+	   allocate element.  */
+	free (old);
     }
 
 #ifdef	HAVE_GNU_LD