This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

__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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]