[llvm] r313746 - [yaml2obj] - Don't crash on invalid document.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 20 02:57:11 PDT 2017
Author: grimar
Date: Wed Sep 20 02:57:11 2017
New Revision: 313746
URL: http://llvm.org/viewvc/llvm-project?rev=313746&view=rev
Log:
[yaml2obj] - Don't crash on invalid document.
Previously jaml2obj would segfault on empty document.
(without yaml description).
Patch fixes the issue.
Differential revision: https://reviews.llvm.org/D38036
Added:
llvm/trunk/test/Object/yaml2obj-invalid.yaml
Modified:
llvm/trunk/include/llvm/Support/YAMLTraits.h
Modified: llvm/trunk/include/llvm/Support/YAMLTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/YAMLTraits.h?rev=313746&r1=313745&r2=313746&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/YAMLTraits.h (original)
+++ llvm/trunk/include/llvm/Support/YAMLTraits.h Wed Sep 20 02:57:11 2017
@@ -1418,8 +1418,8 @@ inline typename std::enable_if<has_Mappi
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;
}
Added: llvm/trunk/test/Object/yaml2obj-invalid.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/yaml2obj-invalid.yaml?rev=313746&view=auto
==============================================================================
--- llvm/trunk/test/Object/yaml2obj-invalid.yaml (added)
+++ llvm/trunk/test/Object/yaml2obj-invalid.yaml Wed Sep 20 02:57:11 2017
@@ -0,0 +1,2 @@
+# RUN: not yaml2obj %s 2>&1 | FileCheck %s
+# CHECK: Unknown document type!
More information about the llvm-commits
mailing list