* libc/reent/reent.c (_reclaim_reent): Make a block from MP-related

statements in _REENT_SMALL case.  Check if _atexit is not NULL before
	dereferencing it.
	(_wrapup_reent): Check if _atexit is not NULL before dereferencing it.
This commit is contained in:
Corinna Vinschen 2009-03-06 17:11:20 +00:00
parent 6f57cb4a52
commit e94fc807d9
2 changed files with 16 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2009-03-06 Hans-Erik Floryd <hans-erik.floryd@rt-labs.com>,
Corinna Vinschen <corinna@vinschen.de>
* libc/reent/reent.c (_reclaim_reent): Make a block from MP-related
statements in _REENT_SMALL case. Check if _atexit is not NULL before
dereferencing it.
(_wrapup_reent): Check if _atexit is not NULL before dereferencing it.
2009-03-06 Corinna Vinschen <corinna@vinschen.de> 2009-03-06 Corinna Vinschen <corinna@vinschen.de>
* libc/include/stdio.h (__VALIST): Guard against multiple definition. * libc/include/stdio.h (__VALIST): Guard against multiple definition.

View File

@ -50,6 +50,7 @@ _DEFUN (_reclaim_reent, (ptr),
/* used by mprec routines. */ /* used by mprec routines. */
#ifdef _REENT_SMALL #ifdef _REENT_SMALL
if (ptr->_mp) /* don't bother allocating it! */ if (ptr->_mp) /* don't bother allocating it! */
{
#endif #endif
if (_REENT_MP_FREELIST(ptr)) if (_REENT_MP_FREELIST(ptr))
{ {
@ -71,6 +72,9 @@ _DEFUN (_reclaim_reent, (ptr),
} }
if (_REENT_MP_RESULT(ptr)) if (_REENT_MP_RESULT(ptr))
_free_r (ptr, _REENT_MP_RESULT(ptr)); _free_r (ptr, _REENT_MP_RESULT(ptr));
#ifdef _REENT_SMALL
}
#endif
#ifdef _REENT_SMALL #ifdef _REENT_SMALL
if (ptr->_emergency) if (ptr->_emergency)
@ -83,7 +87,7 @@ _DEFUN (_reclaim_reent, (ptr),
_free_r (ptr, ptr->_localtime_buf); _free_r (ptr, ptr->_localtime_buf);
if (ptr->_asctime_buf) if (ptr->_asctime_buf)
_free_r (ptr, ptr->_asctime_buf); _free_r (ptr, ptr->_asctime_buf);
if (ptr->_atexit->_on_exit_args_ptr) if (ptr->_atexit && ptr->_atexit->_on_exit_args_ptr)
_free_r (ptr, ptr->_atexit->_on_exit_args_ptr); _free_r (ptr, ptr->_atexit->_on_exit_args_ptr);
#else #else
/* atexit stuff */ /* atexit stuff */
@ -130,11 +134,11 @@ _DEFUN (_wrapup_reent, (ptr), struct _reent *ptr)
register struct _atexit *p; register struct _atexit *p;
register int n; register int n;
if (ptr == 0) if (ptr == NULL)
ptr = _REENT; ptr = _REENT;
#ifdef _REENT_SMALL #ifdef _REENT_SMALL
for (p = &ptr->_atexit, n = p->_ind; --n >= 0;) for (p = ptr->_atexit, n = p ? p->_ind : 0; --n >= 0;)
(*p->_fns[n]) (); (*p->_fns[n]) ();
#else #else
for (p = ptr->_atexit; p; p = p->_next) for (p = ptr->_atexit; p; p = p->_next)