This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add missing lock releases in __register_exitproc().


>From 226aeb4f502fc9404567062f68d527ef012ea683 Sat, 12 Dec 2015 15:07:48 +0100
From: Freddie Chopin <freddie.chopin@gmail.com>
Date: Sat, 12 Dec 2015 11:52:21 +0100
Subject: [PATCH] Add missing lock releases in __register_exitproc().


In some code paths the __atexit_lock held by this function was not
released when returning with an error.

        * libc/stdlib/__atexit.c (__register_exitproc): Always release
        lock before return.

diff --git a/newlib/libc/stdlib/__atexit.c b/newlib/libc/stdlib/__atexit.c
index 18edc8c..a3d5bdf 100644
--- a/newlib/libc/stdlib/__atexit.c
+++ b/newlib/libc/stdlib/__atexit.c
@@ -83,12 +83,20 @@
   if (p->_ind >= _ATEXIT_SIZE)
     {
 #ifndef _ATEXIT_DYNAMIC_ALLOC
+#ifndef __SINGLE_THREAD__
+      __lock_release_recursive(__atexit_lock);
+#endif
       return -1;
 #else
       /* Don't dynamically allocate the atexit array if malloc is not
 	 available.  */
       if (!malloc)
-	return -1;
+	{
+#ifndef __SINGLE_THREAD__
+	  __lock_release_recursive(__atexit_lock);
+#endif
+	  return -1;
+	}
 
       p = (struct _atexit *) malloc (sizeof *p);
       if (p == NULL)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]