]> sourceware.org Git - newlib-cygwin.git/commitdiff
Fix atexit logic to honor _ATEXIT_DYNAMIC_ALLOC setting.
authorJeff Johnston <jjohnstn@redhat.com>
Mon, 21 Dec 2015 16:53:14 +0000 (11:53 -0500)
committerJeff Johnston <jjohnstn@redhat.com>
Mon, 21 Dec 2015 16:53:14 +0000 (11:53 -0500)
If small reent is enabled (_REENT_SMALL is defined) then malloc() was
used in __register_exitproc() even if user requested it to be disabled
(_ATEXIT_DYNAMIC_ALLOC is defined). With this fix, function fails when
_ATEXIT_DYNAMIC_ALLOC is defined and whole static storage is already
used.

2015-12-21  Freddie Chopin  <freddie.chopin@gmail.com>

        * libc/stdlib/__atexit.c (__register_exitproc): Fix for
        _ATEXIT_DYNAMIC_ALLOC.

newlib/ChangeLog
newlib/libc/stdlib/__atexit.c

index 480eb863fbcf13d5ffaf4f6fb9116ea62864a216..736def6b8382327f02589066005deb95acf0c318 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-21  Freddie Chopin  <freddie.chopin@gmail.com>
+
+       * libc/stdlib/__atexit.c (__register_exitproc): Fix for
+       _ATEXIT_DYNAMIC_ALLOC.
+
 2015-12-21  Freddie Chopin  <freddie.chopin@gmail.com>
 
        * libc/stdlib/on_exit_args.{c,h}: New files.
index 23eab29a9e4aa8ec5420a6c9c00a2f169e28585d..d07f6c122af78ad94e3e126243a8e850924a8dcf 100644 (file)
@@ -131,6 +131,12 @@ _DEFUN (__register_exitproc,
       args = p->_on_exit_args_ptr;
       if (args == NULL)
        {
+#ifndef _ATEXIT_DYNAMIC_ALLOC
+#ifndef __SINGLE_THREAD__
+         __lock_release_recursive(__atexit_lock);
+#endif
+         return -1;
+#else
          if (malloc)
            args = malloc (sizeof * p->_on_exit_args_ptr);
 
@@ -144,6 +150,7 @@ _DEFUN (__register_exitproc,
          args->_fntypes = 0;
          args->_is_cxa = 0;
          p->_on_exit_args_ptr = args;
+#endif
        }
 #else
       args = &p->_on_exit_args;
This page took 0.047558 seconds and 5 git commands to generate.