[llvm] [yaml2obj] Don't use uninitialized Type (PR #123274)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 15:32:16 PST 2025


================
@@ -1599,8 +1599,11 @@ void MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::mapping(
     // When the Type string does not have a "SHT_" prefix, we know it is not a
     // description of a regular ELF output section.
     TypeStr = getStringValue(IO, "Type");
-    if (TypeStr.starts_with("SHT_") || isInteger(TypeStr))
+    if (TypeStr.starts_with("SHT_") || isInteger(TypeStr)) {
       IO.mapRequired("Type", Type);
+      if (IO.error())
+        Type = ELF::SHT_NULL;
+    }
----------------
fmayer wrote:

No, I mean else of 
```
if (TypeStr.starts_with("SHT_") || isInteger(TypeStr)) {
```

https://github.com/llvm/llvm-project/pull/123274


More information about the llvm-commits mailing list