summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/imfs/imfs_unlink.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2003-06-10 17:32:00 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2003-06-10 17:32:00 +0000
commit54411933a5af5b2f0c66c37dcdc77ca163c6997c (patch)
tree1051585fc9772c9b0c13939a727e00ffec1e4260 /cpukit/libfs/src/imfs/imfs_unlink.c
parent79ce8b2fd5235128c694536873984730721af1cd (diff)
downloadrtems-54411933a5af5b2f0c66c37dcdc77ca163c6997c.tar.bz2
2003-06-10 Phil Torre <ptorre@zetron.com>
PR 411/filesystem * src/imfs/imfs_unlink.c: Fix bug where renaming a memfile and then unlinking it causes a memory leak.
Diffstat (limited to 'cpukit/libfs/src/imfs/imfs_unlink.c')
-rw-r--r--cpukit/libfs/src/imfs/imfs_unlink.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/cpukit/libfs/src/imfs/imfs_unlink.c b/cpukit/libfs/src/imfs/imfs_unlink.c
index 9e0861b53a..af89045dc0 100644
--- a/cpukit/libfs/src/imfs/imfs_unlink.c
+++ b/cpukit/libfs/src/imfs/imfs_unlink.c
@@ -58,12 +58,16 @@ int IMFS_unlink(
* to remove the node that is a link and the node itself.
*/
- node->info.hard_link.link_node->st_nlink --;
- IMFS_update_ctime( node->info.hard_link.link_node );
- if ( node->info.hard_link.link_node->st_nlink < 1) {
- result = (*the_link.handlers->rmnod_h)( &the_link );
- if ( result != 0 )
- return -1;
+ if ( node->info.hard_link.link_node->st_nlink == 1)
+ {
+ result = (*the_link.handlers->rmnod_h)( &the_link );
+ if ( result != 0 )
+ return -1;
+ }
+ else
+ {
+ node->info.hard_link.link_node->st_nlink --;
+ IMFS_update_ctime( node->info.hard_link.link_node );
}
}