summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/unlink.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2010-02-16 01:47:46 +0000
committerChris Johns <chrisj@rtems.org>2010-02-16 01:47:46 +0000
commitb3b8add4b425709c711ff1515754b09b755aad11 (patch)
tree2c6dc1a1570eeb26066acb2a76b013d5251eebeb /cpukit/libcsupport/src/unlink.c
parentThis commit was generated by cvs2svn to compensate for changes in r22653, (diff)
downloadrtems-b3b8add4b425709c711ff1515754b09b755aad11.tar.bz2
2010-02-16 Chris Johns <chrisj@rtems.org>
* libcsupport/src/open.c: Tighten the open handler check. 2010-02-16 Sebastian Huber <sebastian.huber@embedded-brains.de> * libcsupport/src/rmdir.c, libcsupport/src/unlink.c: Free the allocated pathloc.
Diffstat (limited to 'cpukit/libcsupport/src/unlink.c')
-rw-r--r--cpukit/libcsupport/src/unlink.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/cpukit/libcsupport/src/unlink.c b/cpukit/libcsupport/src/unlink.c
index 359e64b4bc..c5c707d3a8 100644
--- a/cpukit/libcsupport/src/unlink.c
+++ b/cpukit/libcsupport/src/unlink.c
@@ -30,6 +30,7 @@ int unlink(
rtems_filesystem_location_info_t loc;
int i;
int result;
+ bool free_parentloc = false;
/*
* Get the node to be unlinked. Find the parent path first.
@@ -46,6 +47,8 @@ int unlink(
false );
if ( result != 0 )
return -1;
+
+ free_parentloc = true;
}
/*
@@ -59,32 +62,37 @@ int unlink(
result = rtems_filesystem_evaluate_relative_path( name , strlen( name ),
0, &loc, false );
if ( result != 0 ) {
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
return -1;
}
if ( !loc.ops->node_type_h ) {
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
rtems_set_errno_and_return_minus_one( ENOTSUP );
}
if ( (*loc.ops->node_type_h)( &loc ) == RTEMS_FILESYSTEM_DIRECTORY ) {
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
rtems_set_errno_and_return_minus_one( EISDIR );
}
if ( !loc.ops->unlink_h ) {
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
rtems_set_errno_and_return_minus_one( ENOTSUP );
}
result = (*loc.ops->unlink_h)( &parentloc, &loc );
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
return result;
}