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.
This commit is contained in:
Freddie Chopin 2015-12-12 11:52:21 +01:00 committed by Corinna Vinschen
parent ecfba2bb2c
commit c39ad27d9e
2 changed files with 14 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2015-12-12 Freddie Chopin <freddie.chopin@gmail.com>
* libc/stdlib/__atexit.c (__register_exitproc): Always release
lock before return.
2015-12-09 Thomas Preud'homme <thomas.preudhomme@arm.com> 2015-12-09 Thomas Preud'homme <thomas.preudhomme@arm.com>
* libm/machine/arm/s_ceil.c: Also check that 64bit FP instructions are * libm/machine/arm/s_ceil.c: Also check that 64bit FP instructions are

View File

@ -83,12 +83,20 @@ _DEFUN (__register_exitproc,
if (p->_ind >= _ATEXIT_SIZE) if (p->_ind >= _ATEXIT_SIZE)
{ {
#ifndef _ATEXIT_DYNAMIC_ALLOC #ifndef _ATEXIT_DYNAMIC_ALLOC
#ifndef __SINGLE_THREAD__
__lock_release_recursive(__atexit_lock);
#endif
return -1; return -1;
#else #else
/* Don't dynamically allocate the atexit array if malloc is not /* Don't dynamically allocate the atexit array if malloc is not
available. */ available. */
if (!malloc) if (!malloc)
return -1; {
#ifndef __SINGLE_THREAD__
__lock_release_recursive(__atexit_lock);
#endif
return -1;
}
p = (struct _atexit *) malloc (sizeof *p); p = (struct _atexit *) malloc (sizeof *p);
if (p == NULL) if (p == NULL)