[PATCH] D38036: [yaml2obj] - Don't crash on invalid document.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 20 07:33:47 PDT 2017
grimar updated this revision to Diff 115997.
grimar added a comment.
This revision is now accepted and ready to land.
- Changed approach to stop breaking tests from Support/YAMLIOTest.cpp.
https://reviews.llvm.org/D38036
Files:
lib/ObjectYAML/ObjectYAML.cpp
test/Object/yaml2obj-invalid.yaml
Index: test/Object/yaml2obj-invalid.yaml
===================================================================
--- test/Object/yaml2obj-invalid.yaml
+++ test/Object/yaml2obj-invalid.yaml
@@ -0,0 +1,2 @@
+# RUN: not yaml2obj %s 2>&1 | FileCheck %s
+# CHECK: Unknown document type!
Index: lib/ObjectYAML/ObjectYAML.cpp
===================================================================
--- lib/ObjectYAML/ObjectYAML.cpp
+++ lib/ObjectYAML/ObjectYAML.cpp
@@ -33,6 +33,10 @@
MappingTraits<MachOYAML::UniversalBinary>::mapping(IO,
*ObjectFile.FatMachO);
} else {
+ // Nothing to parse, return.
+ if (!((Input &)IO).getCurrentNode())
+ return;
+
if (IO.mapTag("!ELF")) {
ObjectFile.Elf.reset(new ELFYAML::Object());
MappingTraits<ELFYAML::Object>::mapping(IO, *ObjectFile.Elf);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38036.115997.patch
Type: text/x-patch
Size: 869 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170920/a1ab887e/attachment.bin>
More information about the llvm-commits
mailing list