summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2009-03-06 17:11:20 +0000
committerCorinna Vinschen <corinna@vinschen.de>2009-03-06 17:11:20 +0000
commite94fc807d905280fb30e46535a639932325b9058 (patch)
tree05d47239fa805288f37b97f92c5ed2f5605f3c97
parent6f57cb4a52ff6dfa4a8b3b489e8e0a8fb03f917c (diff)
downloadcygnal-e94fc807d905280fb30e46535a639932325b9058.tar.gz
cygnal-e94fc807d905280fb30e46535a639932325b9058.tar.bz2
cygnal-e94fc807d905280fb30e46535a639932325b9058.zip
* 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.
-rw-r--r--newlib/ChangeLog8
-rw-r--r--newlib/libc/reent/reent.c12
2 files changed, 16 insertions, 4 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 7c8a6406f..c5b942fda 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -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>
* libc/include/stdio.h (__VALIST): Guard against multiple definition.
diff --git a/newlib/libc/reent/reent.c b/newlib/libc/reent/reent.c
index 5270ef6eb..3c9de71f7 100644
--- a/newlib/libc/reent/reent.c
+++ b/newlib/libc/reent/reent.c
@@ -50,6 +50,7 @@ _DEFUN (_reclaim_reent, (ptr),
/* used by mprec routines. */
#ifdef _REENT_SMALL
if (ptr->_mp) /* don't bother allocating it! */
+ {
#endif
if (_REENT_MP_FREELIST(ptr))
{
@@ -71,6 +72,9 @@ _DEFUN (_reclaim_reent, (ptr),
}
if (_REENT_MP_RESULT(ptr))
_free_r (ptr, _REENT_MP_RESULT(ptr));
+#ifdef _REENT_SMALL
+ }
+#endif
#ifdef _REENT_SMALL
if (ptr->_emergency)
@@ -83,7 +87,7 @@ _DEFUN (_reclaim_reent, (ptr),
_free_r (ptr, ptr->_localtime_buf);
if (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);
#else
/* atexit stuff */
@@ -130,11 +134,11 @@ _DEFUN (_wrapup_reent, (ptr), struct _reent *ptr)
register struct _atexit *p;
register int n;
- if (ptr == 0)
- ptr = _REENT;
+ if (ptr == NULL)
+ ptr = _REENT;
#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]) ();
#else
for (p = ptr->_atexit; p; p = p->_next)