summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2003-11-26 17:53:30 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2003-11-26 17:53:30 +0000
commitc9a4da01c6d7e6f55e6c30769c410ca5e956dcd3 (patch)
tree012033a25a713e63bdaf6cfee3a64d9f363ddd2d /cpukit
parent2003-11-26 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-c9a4da01c6d7e6f55e6c30769c410ca5e956dcd3.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')
-rw-r--r--cpukit/libcsupport/ChangeLog6
-rw-r--r--cpukit/libcsupport/src/newlibc.c28
2 files changed, 34 insertions, 0 deletions
diff --git a/cpukit/libcsupport/ChangeLog b/cpukit/libcsupport/ChangeLog
index eb44f4a487..a2304b2797 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