summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/YAMLTraits.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-04-25 09:59:55 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-04-25 09:59:55 +0000
commit45d042ed961a04b641eac99584b045de27388708 (patch)
tree670437cf48e6a91a3efadbd6b07681738b60ec9d /llvm/lib/Support/YAMLTraits.cpp
parent4b7d3c48317c064e6a7048f7eee14677f1fddcc5 (diff)
downloadbcm5719-llvm-45d042ed961a04b641eac99584b045de27388708.tar.gz
bcm5719-llvm-45d042ed961a04b641eac99584b045de27388708.zip
[yaml2obj] - Don't crash on invalid inputs.
yaml2obj might crash on invalid input when unable to parse the YAML. Recently a crash with a very similar nature was fixed for an empty files. This patch revisits the fix and does it in yaml::Input instead. It seems to be more correct way to handle such situation. With that crash for invalid inputs is also fixed now. Differential revision: https://reviews.llvm.org/D61059 llvm-svn: 359178
Diffstat (limited to 'llvm/lib/Support/YAMLTraits.cpp')
-rw-r--r--llvm/lib/Support/YAMLTraits.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp
index e7932fe4239..183da5b3900 100644
--- a/llvm/lib/Support/YAMLTraits.cpp
+++ b/llvm/lib/Support/YAMLTraits.cpp
@@ -113,6 +113,11 @@ const Node *Input::getCurrentNode() const {
}
bool Input::mapTag(StringRef Tag, bool Default) {
+ // CurrentNode can be null if setCurrentDocument() was unable to
+ // parse the document because it was invalid or empty.
+ if (!CurrentNode)
+ return false;
+
std::string foundTag = CurrentNode->_node->getVerbatimTag();
if (foundTag.empty()) {
// If no tag found and 'Tag' is the default, say it was found.
OpenPOWER on IntegriCloud