This is the mail archive of the newlib@sources.redhat.com 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]

asprintf in low memory situations


Hi,

it seems that NEWLIB's asprintf does not
free an allocated buffer in fp->_bf._base
when a call to _realloc_r() fails.

This is somewhat different to the BSD and GLIBC
implementation. BSD LIBC seems to call free() and 
set the return pointer to NULL while GLIBC 
(according to man page) seems to call free()
and return the now invalid pointer.

I'm just curious whether this is a design issue or a bug.
However, it is an portability issue.
In the error case one has to call free() on NEWLIB systems,
can call free() on BSD systems and must not call 
free() on GLIBC systems.

I've discovered this on a RTEMS target, but it
should be the same for all targets.

Please reply directly, as I'm not a subscriber of this
mailing list.

Many thanks in advance,
Thomas.

--
Thomas Rauscher
LOYTEC electronics GmbH
Stolzenthalergasse 24/3
A-1080 Wien
Austria/Europe
trauscher@loytec.com
www.loytec.com
Phone: +43-1-4020805-15
FAX:   +43-1-4020805-99


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