#1242 closed defect (fixed)

errant free in imfs_rmnod.c

Reported by: Ralf Corsepius Owned by: Joel Sherrill
Priority: normal Milestone: 4.7
Component: fs Version: 4.7
Severity: major Keywords:
Cc: sebastian.huber@… Blocked By:
Blocking:

Description

Near to the end of cpukit/libfs/src/imfs/imfs_rmnod.c, this code can be found:

if ( the_jnode->type == IMFS_SYM_LINK ) {

if ( the_jnode->info.sym_link.name )

free( the_jnode->info.sym_link.name );

}
free( the_jnode );

GCC warns about it:
../../../../../../../rtems.orig/c/src/../../cpukit/libfs/src/imfs/imfs_rmnod.c: In function 'IMFS_rmnod':
../../../../../../../rtems.orig/c/src/../../cpukit/libfs/src/imfs/imfs_rmnod.c:76: warning: passing argument 1 of 'free' discards qualifiers from pointer target type

AFAIU, the_jnode->info.sym_link.name is a "const char*", i.e. it contains the address, but doesn't own the string.
=> the "free( the_jnode->info.sym_link.name );" is very likely wrong, and likely to cause memory faults.

Change History (2)

comment:1 Changed on Apr 24, 2008 at 1:13:26 PM by Sebastian Huber

Cc: Sebastian Huber added

comment:2 Changed on May 27, 2008 at 12:32:34 PM by Sebastian Huber

Resolution: fixed
Status: newclosed

Fixed in CVS.

Note: See TracTickets for help on using tickets.