diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2003-11-26 17:53:41 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2003-11-26 17:53:41 +0000 |
commit | 294daf49c01b456c93617cbdfbeb8837a89113d7 (patch) | |
tree | 44f5769993814175dbf0e45ca39a81a034cc1e48 /cpukit/libcsupport | |
parent | 2003-11-26 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-294daf49c01b456c93617cbdfbeb8837a89113d7.tar.bz2 |
2003-11-26 Joel Sherrill <joel@OARcorp.com>
PR 524/filesystem
* src/newlibc.c: Address 1K buffer leak from incomplete cleanup of
newlib reentrancy handler.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r-- | cpukit/libcsupport/ChangeLog | 6 | ||||
-rw-r--r-- | cpukit/libcsupport/src/newlibc.c | 28 |
2 files changed, 34 insertions, 0 deletions
diff --git a/cpukit/libcsupport/ChangeLog b/cpukit/libcsupport/ChangeLog index 50ed7f9d15..640f339a68 100644 --- a/cpukit/libcsupport/ChangeLog +++ b/cpukit/libcsupport/ChangeLog @@ -1,5 +1,11 @@ 2003-11-26 Joel Sherrill <joel@OARcorp.com> + PR 524/filesystem + * src/newlibc.c: Address 1K buffer leak from incomplete cleanup of + newlib reentrancy handler. + +2003-11-26 Joel Sherrill <joel@OARcorp.com> + PR 523/filesystem * src/malloc.c: Make malloc family safer for use from ISRs and dispatching critical sections. If in a critical section while doing diff --git a/cpukit/libcsupport/src/newlibc.c b/cpukit/libcsupport/src/newlibc.c index 13c600731a..dcd7dae3b2 100644 --- a/cpukit/libcsupport/src/newlibc.c +++ b/cpukit/libcsupport/src/newlibc.c @@ -42,6 +42,8 @@ #include <stdio.h> +int _fwalk(struct _reent *ptr, int (*function) (FILE *) ); + int libc_reentrant; /* do we think we are reentrant? */ struct _reent libc_global_reent; @@ -196,6 +198,26 @@ rtems_extension libc_begin_hook(rtems_tcb *current_task) * */ +int newlib_free_buffers( + FILE *fp +) +{ + switch ( fileno(fp) ) { + case 0: + case 1: + case 2: + if (fp->_flags & __SMBF) { + free( fp->_bf._base ); + fp->_flags &= ~__SMBF; + fp->_bf._base = fp->_p = (unsigned char *) NULL; + } + break; + default: + fclose(fp); + } + return 0; +} + rtems_extension libc_delete_hook( rtems_tcb *current_task, rtems_tcb *deleted_task @@ -215,8 +237,14 @@ rtems_extension libc_delete_hook( /* if (ptr) */ if (ptr && ptr != &libc_global_reent) { +/* _wrapup_reent(ptr); _reclaim_reent(ptr); +*/ + /* + * Just in case there are some buffers lying around. + */ + _fwalk(ptr, newlib_free_buffers); #if REENT_MALLOCED free(ptr); #else |