#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 Dec 3, 2006 at 1:31:13 PM.
pr479.diff

Download all attachments as: .zip

Change History (3)

comment:1 Changed on Sep 4, 2003 at 11:43:15 AM 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 Dec 3, 2006 at 1:31:13 PM by kamen

Attachment: pr479.diff added

pr479.diff

comment:2 Changed on Oct 10, 2017 at 6:35:44 AM by Sebastian Huber

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