[llvm-branch-commits] [YAML] Don't validate `Fill::Size` after error (PR #123280)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 16 20:10:11 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-objectyaml
Author: Vitaly Buka (vitalybuka)
<details>
<summary>Changes</summary>
Size is required, so we don't know if it's in
uninitialized state after the previous error.
Triggers msan on llvm/test/tools/yaml2obj/ELF/custom-fill.yaml
---
Full diff: https://github.com/llvm/llvm-project/pull/123280.diff
1 Files Affected:
- (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+3-1)
``````````diff
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index e0e941cff94c52..1d52cdef79400f 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -1750,7 +1750,9 @@ void MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::mapping(
std::string MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::validate(
IO &io, std::unique_ptr<ELFYAML::Chunk> &C) {
if (const auto *F = dyn_cast<ELFYAML::Fill>(C.get())) {
- if (F->Pattern && F->Pattern->binary_size() != 0 && !F->Size)
+ // Can't check the `Size`, as it's required and may be left uninitialized by
+ // previous error.
+ if (!io.error() && F->Pattern && F->Pattern->binary_size() != 0 && !F->Size)
return "\"Size\" can't be 0 when \"Pattern\" is not empty";
return "";
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/123280
More information about the llvm-branch-commits
mailing list