From 54411933a5af5b2f0c66c37dcdc77ca163c6997c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 10 Jun 2003 17:32:00 +0000 Subject: 2003-06-10 Phil Torre PR 411/filesystem * src/imfs/imfs_unlink.c: Fix bug where renaming a memfile and then unlinking it causes a memory leak. --- cpukit/libfs/src/imfs/imfs_unlink.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'cpukit/libfs/src/imfs/imfs_unlink.c') 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 ); } } -- cgit v1.2.3