[PATCH] D38036: [yaml2obj] - Don't crash on invalid document.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 19 06:56:39 PDT 2017
grimar created this revision.
Previously jaml2obj would segfault on empty document.
(without yaml description).
Patch fixes the issue.
https://reviews.llvm.org/D38036
Files:
include/llvm/Support/YAMLTraits.h
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: include/llvm/Support/YAMLTraits.h
===================================================================
--- include/llvm/Support/YAMLTraits.h
+++ include/llvm/Support/YAMLTraits.h
@@ -1418,8 +1418,8 @@
Input &>::type
operator>>(Input &yin, T &docMap) {
EmptyContext Ctx;
- yin.setCurrentDocument();
- yamlize(yin, docMap, true, Ctx);
+ if (yin.setCurrentDocument())
+ yamlize(yin, docMap, true, Ctx);
return yin;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38036.115836.patch
Type: text/x-patch
Size: 746 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170919/8e996480/attachment.bin>
More information about the llvm-commits
mailing list