dual-image: Do not erase image if os-release is not found

The code will erase an image if the os-release is not found.
For dual image, the secondary flash may be empty or contains invalid
data, e.g. in factory or lab, so it should just ignore such case instead
of erasing the image.

Without the change, when it tries to erase the image, it crashes in
erase() because the version ID is not available and the code was
accessing the invalidated iterator.

Tested: Verify the crash is fixed in QEMU when the secondary image is
        empty.

Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I7a1a8da15c31045fc7d51416f6ba0875349067d2
diff --git a/item_updater.cpp b/item_updater.cpp
index ceabde5..ea7cb2d 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -193,6 +193,11 @@
             auto osRelease = iter.path() / releaseFile.relative_path();
             if (!fs::is_regular_file(osRelease))
             {
+#ifdef BMC_STATIC_DUAL_IMAGE
+                // For dual image, it is possible that the secondary image is
+                // empty or contains invalid data, ignore such case.
+                info("Unable to find osRelease: {PATH}", "PATH", osRelease);
+#else
                 error("Failed to read osRelease: {PATH}", "PATH", osRelease);
 
                 // Try to get the version id from the mount directory name and
@@ -202,6 +207,7 @@
                 // erase() is called with an non-existent id and returns.
                 auto id = iter.path().native().substr(BMC_RO_PREFIX_LEN);
                 ItemUpdater::erase(id);
+#endif
 
                 continue;
             }