diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2003-09-04 13:02:57 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2003-09-04 13:02:57 +0000 |
commit | d9c3805a73aea84f5c054e4022ada63e28ce6b99 (patch) | |
tree | 8757185f5481f2c34ebd647c37e6b5206551d66e /cpukit | |
parent | 2003-09-04 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-d9c3805a73aea84f5c054e4022ada63e28ce6b99.tar.bz2 |
2003-09-04 Joel Sherrill <joel@OARcorp.com>
PR 479/rtems_misc
* src/malloc.c: Per multiple standards realloc does not free the
original memory if the allocation of the requested larger block
fails.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/libcsupport/ChangeLog | 7 | ||||
-rw-r--r-- | cpukit/libcsupport/src/malloc.c | 7 |
2 files changed, 13 insertions, 1 deletions
diff --git a/cpukit/libcsupport/ChangeLog b/cpukit/libcsupport/ChangeLog index 7a58a5479c..b0f8be89fb 100644 --- a/cpukit/libcsupport/ChangeLog +++ b/cpukit/libcsupport/ChangeLog @@ -1,3 +1,10 @@ +2003-09-04 Joel Sherrill <joel@OARcorp.com> + + PR 479/rtems_misc + * src/malloc.c: Per multiple standards realloc does not free the + original memory if the allocation of the requested larger block + fails. + 2003-09-02 Joel Sherrill <joel@OARcorp.com> * src/open.c: Fix typo. diff --git a/cpukit/libcsupport/src/malloc.c b/cpukit/libcsupport/src/malloc.c index e89408284d..b8139e8370 100644 --- a/cpukit/libcsupport/src/malloc.c +++ b/cpukit/libcsupport/src/malloc.c @@ -279,8 +279,13 @@ void *realloc( MSBUMP(malloc_calls, -1); /* subtract off the malloc */ + /* + * There used to be a free on this error case but it is wrong to + * free the memory per OpenGroup Single UNIX Specification V2 + * and the C Standard. + */ + if ( !new_area ) { - free( ptr ); return (void *) 0; } |