This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
__sinit - NULL pointers from __sfp with _REENT_SMALL
- From: "Matt Lee" <reachmatt dot lee at gmail dot com>
- To: newlib at sources dot redhat dot com
- Date: Tue, 4 Sep 2007 17:23:37 -0700
- Subject: __sinit - NULL pointers from __sfp with _REENT_SMALL
I have a suggestion for a minor enhancement.
_sinit does not seem to check for NULL pointers when assigning file
structures using __sfp under _REENT_SMALL.
findfp.c:
#ifndef _REENT_SMALL
s->__sglue._niobs = 3;
s->__sglue._iobs = &s->__sf[0];
#else
s->__sglue._niobs = 0;
s->__sglue._iobs = NULL;
s->_stdin = __sfp(s);
s->_stdout = __sfp(s);
s->_stderr = __sfp(s);
#endif
std (s->_stdin, __SRD, 0, s);
This will happen when the heap size is too small or even zero. This is
not uncommon in some embedded systems. While the user eventually does
need to allocate more heap space, he will not get a graceful failure
when there is not enough.
__sinit does not return any status and stdio will require rework to
propagate the error back to callers. Any suggestions on the best way
to handle this error in my architecture? Are assertions accepted
practice to trap such situations?
Lastly, should I file a bug report?
--
thanks,
Matt