summaryrefslogtreecommitdiff
path: root/cpukit/libcsupport/src/rmdir.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/rmdir.c
parentfcc69714b36623ec0adb4944132b3c28126c5e1b (diff)
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/rmdir.c')
-rw-r--r--cpukit/libcsupport/src/rmdir.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/cpukit/libcsupport/src/rmdir.c b/cpukit/libcsupport/src/rmdir.c
index b66837e115..671cb1a05a 100644
--- a/cpukit/libcsupport/src/rmdir.c
+++ b/cpukit/libcsupport/src/rmdir.c
@@ -34,6 +34,7 @@ int rmdir(
rtems_filesystem_location_info_t loc;
int i;
int result;
+ bool free_parentloc = false;
/*
* Get the parent node of the node we wish to remove. Find the parent path.
@@ -50,6 +51,8 @@ int rmdir(
false );
if ( result != 0 )
return -1;
+
+ free_parentloc = true;
}
/*
@@ -63,7 +66,8 @@ int rmdir(
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;
}
@@ -73,13 +77,15 @@ int rmdir(
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( ENOTDIR );
}
@@ -89,14 +95,16 @@ int rmdir(
if ( !loc.handlers->rmnod_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.handlers->rmnod_h)( &parentloc, &loc );
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
return result;
}