]> git.sven.stormbind.net Git - sven/exfat-utils.git/blobdiff - libexfat/node.c
Imported Upstream version 1.2.3
[sven/exfat-utils.git] / libexfat / node.c
index d05f20dc15aecb729c52557186a778eb8530e368..4dd4dc6a4c6085a8a8f3622609951451aa7b2d87 100644 (file)
@@ -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);