diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 935daa5b5..d5224cd2b 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2012-06-05 Corinna Vinschen + + * libc/stdio/findfp.c (__sinit): Avoid infinite recursion on + _REENT_SMALL targets. Add comment to explain. + 2012-05-31 Corinna Vinschen * libc/stdio/local.h (_newlib_sfp_lock_exit): Fix typo in non-pthread diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index e39660cd4..0beb1e5b0 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -200,6 +200,11 @@ _DEFUN(__sinit, (s), #else s->__sglue._niobs = 0; s->__sglue._iobs = NULL; + /* Avoid infinite recursion when calling __sfp for _GLOBAL_REENT. The + problem is that __sfp checks for _GLOBAL_REENT->__sdidinit and calls + __sinit if it's 0. */ + if (s == _GLOBAL_REENT) + s->__sdidinit = 1; s->_stdin = __sfp(s); s->_stdout = __sfp(s); s->_stderr = __sfp(s);