This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH] Add missing lock releases in __register_exitproc().
- From: Freddie Chopin <freddie dot chopin at gmail dot com>
- To: newlib at sourceware dot org
- Date: Sat, 12 Dec 2015 15:10:17 +0100
- Subject: [PATCH] Add missing lock releases in __register_exitproc().
- Authentication-results: sourceware.org; auth=none
>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)