- free_dentry_tree(imd->root_dentry, NULL, false);
-#if 0
- destroy_security_data(&imd->security_data);
-#endif
- imd->root_dentry = NULL;
+ if (!imd->modified) {
+ DEBUG("Freeing image %u", w->current_image);
+ free_dentry_tree(imd->root_dentry, NULL, false);
+ imd->root_dentry = NULL;
+ free_security_data(imd->security_data);
+ imd->security_data = NULL;
+ }