Author: Kazu Hirata Date: 2026-08-27T21:04:41-07:00 New Revision: 58b67ab0055f84cbdc9b440e87adf9176b1b9c2a
URL: https://github.com/llvm/llvm-project/commit/58b67ab0055f84cbdc9b440e87adf9176b1b9c2a DIFF: https://github.com/llvm/llvm-project/commit/58b67ab0055f84cbdc9b440e87adf9176b1b9c2a.diff LOG: [clang][OffloadBundler] Fix uninitialized iterator in BinaryFileHandler (#219346) This patch initializes NextBundleInfo at the top of ReadHeader to prevent an uninitialized iterator comparison. ReadHeader has several early return points where it exits without reading any bundles. Upon an early return, NextBundleInfo never reaches the assignment at the bottom of ReadHeader: NextBundleInfo = BundlesInfo.begin(); leaving NextBundleInfo default-constructed. A subsequent call to ReadBundleStart then attempts an invalid iterator comparison: if (NextBundleInfo == BundlesInfo.end()) where NextBundleInfo is still default-constructed. This bug was discovered with tightened epoch checks in StringMapIterBase. Assisted-by: Antigravity Added: Modified: clang/lib/Driver/OffloadBundler.cpp Removed: ################################################################################ diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp index b397ee4c5b075..2d0c326ab6f40 100644 --- a/clang/lib/Driver/OffloadBundler.cpp +++ b/clang/lib/Driver/OffloadBundler.cpp @@ -357,8 +357,10 @@ class BinaryFileHandler final : public FileHandler { ~BinaryFileHandler() final {} Error ReadHeader(StringRef FC) final { - // Initialize the current bundle with the end of the container. + // Ensure iterators indicate an empty bundle range in case header parsing + // exits early. CurBundleInfo = BundlesInfo.end(); + NextBundleInfo = BundlesInfo.end(); // Check if buffer is smaller than magic string. size_t ReadChars = sizeof(OFFLOAD_BUNDLER_MAGIC_STR) - 1; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
