Skip to content

Commit

Permalink
Fix clusters loss when file renaming replaces target.
Browse files Browse the repository at this point in the history
Add missing exfat_cleanup_node() call after exfat_unlink().
  • Loading branch information
relan committed Dec 19, 2015
1 parent 5bf2c77 commit 1bacc53
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libexfat/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,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);
Expand Down

0 comments on commit 1bacc53

Please sign in to comment.