- /* Stream checksums must be known before proceeding. */
- ret = wim_checksum_unhashed_streams(src_wim);
+ /* We don't yet support having a single WIMStruct contain duplicate
+ * 'image_metadata' structures, so we must forbid this from happening.
+ * A duplication is possible if 'src_wim == dest_wim', if the same image
+ * is exported to the same destination WIMStruct multiple times, or if
+ * an image is exported in an A => B => A manner. */
+ for (src_image = start_src_image;
+ src_image <= end_src_image; src_image++)
+ {
+ const struct wim_image_metadata *src_imd =
+ src_wim->image_metadata[src_image - 1];
+ for (int i = 0; i < dest_wim->hdr.image_count; i++)
+ if (dest_wim->image_metadata[i] == src_imd)
+ return WIMLIB_ERR_DUPLICATE_EXPORTED_IMAGE;
+ }
+
+ /* Blob checksums must be known before proceeding. */
+ ret = wim_checksum_unhashed_blobs(src_wim);