#479 closed defect (fixed)

realloc deallocates argument pointer if new_area cannot be obtained

Reported by: kamen Owned by: Joel Sherrill
Priority: normal Milestone: 2
Component: unspecified Version: 4.5
Severity: major Keywords:
Cc: bugs@… Blocked By:
Blocking:

Description

Accordingly to "C Reference Manual", p. 388, documentation of realloc:

"If the request cannot be satisfied, a null pointer is returned and the old region is not disturbed."

However, the RTEMS definition of realloc contains this:


new_area = malloc( size );


MSBUMP(malloc_calls, -1); /* subtract off the malloc */

if ( !new_area ) {

free( ptr );
return (void *) 0;

}


free( ptr ) is erroneous and should be removed.

Release:
RTEMS-4.5 ss20030417

Environment:
host = Cygwin
target = powerpc

How-To-Repeat:
Allocate an array and keep growing it with realloc until realloc fails.

Attachments (1)

pr479.diff (1.2 KB) - added by kamen on 12/03/06 at 13:31:13.
pr479.diff

Download all attachments as: .zip

Change History (3)

comment:1 Changed on 09/04/03 at 11:43:15 by Joel Sherrill

Status: assignedclosed

State-Changed-From-To: open->closed
State-Changed-Why: Fix in 4.6 branch and trunk. The Open Group Single UNIX

Specificatoin also defines the same behavior. I added a
comment indicating that this really was the desired behavior
so someone in the future won't be tempted to add it again.

Changed on 12/03/06 at 13:31:13 by kamen

Attachment: pr479.diff added

pr479.diff

comment:2 Changed on 10/10/17 at 06:35:44 by Sebastian Huber

Component: miscunspecified
Note: See TracTickets for help on using tickets.