After exporting an image, an inode list may be shared between multiple images.
This is a fix to make deleting the inodes from the list still work when the list
head may have been freed already.
FREE(inode->fds);
pthread_mutex_destroy(&inode->i_mutex);
if (inode->hlist.pprev)
- hlist_del(&inode->hlist);
+ hlist_safe_del(&inode->hlist);
#endif
FREE(inode->extracted_file);
FREE(inode);
dest_wim->image_metadata[
dest_wim->hdr.image_count - 1].inode_list = src_imd->inode_list;
+ if (src_imd->inode_list.first)
+ src_imd->inode_list.first->pprev = NULL;
/* All memory allocations have been taken care of, so it's no longer
* possible for this function to fail. Go ahead and increment the
next->pprev = pprev;
}
+static inline void hlist_safe_del(struct hlist_node *n)
+{
+ struct hlist_node *next = n->next;
+ struct hlist_node **pprev = n->pprev;
+ if (pprev)
+ *pprev = next;
+ if (next)
+ next->pprev = pprev;
+}
+
static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
{
struct hlist_node *first = h->first;
goto out;
}
+ if (imd->inode_list.first)
+ imd->inode_list.first->pprev = &imd->inode_list.first;
+
if (imd->modified) {
ERROR("Cannot mount image that was added "
"with wimlib_add_image()");