- ret = read_lookup_table(w);
- if (ret != 0)
- goto out_close;
-
- w->image_metadata = CALLOC(w->hdr.image_count,
- sizeof(struct image_metadata));
-
- if (!w->image_metadata) {
- ERROR("Failed to allocate memory for %u metadata structures",
- w->hdr.image_count);
- ret = WIMLIB_ERR_NOMEM;
- goto out_free_lookup_table;
- }
- w->current_image = 0;
-
- DEBUG("Looking for metadata resources in the lookup table.");
-
- /* Find the images in the WIM by searching the lookup table. */
- ret = for_lookup_table_entry(w->lookup_table,
- append_metadata_resource_entry, w);
-
- if (ret != 0)
- goto out_free_image_metadata;
-
- /* Make sure all the expected images were found. (We already have
- * returned false if *extra* images were found) */
- if (w->current_image != w->hdr.image_count &&
- w->hdr.part_number == 1)
- {
- ERROR("Only found %u images in WIM, but expected %u",
- w->current_image, w->hdr.image_count);
- ret = WIMLIB_ERR_IMAGE_COUNT;
- goto out_free_image_metadata;
+ if (!w->image_metadata) {
+ ERROR("Failed to allocate memory for %u image metadata structures",
+ w->hdr.image_count);
+ return WIMLIB_ERR_NOMEM;
+ }