wimlib_mount_image(): Delete staging dir on error paths
[wimlib] / src / mount_image.c
index 28a807d7afdfd7d26537a57a97d99e5203564841..a05a822d10d78d0f2dc92b94076acdba5d7a36b4 100644 (file)
@@ -2499,6 +2499,12 @@ WIMLIBAPI int wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
 
        if (ret)
                ret = WIMLIB_ERR_FUSE;
+
+       /* Try to delete the staging directory if a deletion wasn't yet
+        * attempted due to an earlier error */
+       if (ctx.staging_dir_name)
+               delete_staging_dir(&ctx);
+
 out_free_dir_copy:
        FREE(dir_copy);
 out_unlock: