From d9c3805a73aea84f5c054e4022ada63e28ce6b99 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 4 Sep 2003 13:02:57 +0000 Subject: 2003-09-04 Joel Sherrill 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. --- cpukit/libcsupport/ChangeLog | 7 +++++++ cpukit/libcsupport/src/malloc.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'cpukit') 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 + + 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 * 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; } -- cgit v1.2.3