From: relan Date: Sat, 19 Dec 2015 08:16:21 +0000 (+0300) Subject: Fix clusters loss when file renaming replaces target. X-Git-Tag: android-x86-9.0-r1~94 X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fexternal-exfat.git;a=commitdiff_plain;h=1bacc536bb3ef013bc502937ee0d89ed32b253d7 Fix clusters loss when file renaming replaces target. Add missing exfat_cleanup_node() call after exfat_unlink(). --- diff --git a/libexfat/node.c b/libexfat/node.c index d05f20d..4dd4dc6 100644 --- a/libexfat/node.c +++ b/libexfat/node.c @@ -1130,6 +1130,16 @@ int exfat_rename(struct exfat* ef, const char* old_path, const char* new_path) exfat_put_node(ef, existing); if (rc != 0) { + /* free clusters even if something went wrong; overwise they + will be just lost */ + exfat_cleanup_node(ef, existing); + exfat_put_node(ef, dir); + exfat_put_node(ef, node); + return rc; + } + rc = exfat_cleanup_node(ef, existing); + if (rc != 0) + { exfat_put_node(ef, dir); exfat_put_node(ef, node); return rc;