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.
This commit is contained in:
Joel Sherrill
2003-09-04 12:41:29 +00:00
parent cd0bab2d6c
commit 0ccd9daa6e
2 changed files with 13 additions and 1 deletions

View File

@@ -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.

View File

@@ -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;
}