diff options
| author | Puyan Lotfi <puyan@puyan.org> | 2019-03-28 22:55:08 +0000 |
|---|---|---|
| committer | Puyan Lotfi <puyan@puyan.org> | 2019-03-28 22:55:08 +0000 |
| commit | 6c826957532816b4c7d69306aa184372a1c9c698 (patch) | |
| tree | 509c4f3026a61a06c7d7bb3b2fc7695dbc520d18 /llvm/tools/yaml2obj/yaml2obj.cpp | |
| parent | da063e64ebc9b1590aaabd80c8b4c4913fab350e (diff) | |
| download | bcm5719-llvm-6c826957532816b4c7d69306aa184372a1c9c698.tar.gz bcm5719-llvm-6c826957532816b4c7d69306aa184372a1c9c698.zip | |
[yaml2obj] Fixing opening empty yaml files.
Essentially echo "" | yaml2obj crashes. This patch attempts to trim whitespace
and determine if the yaml string in the file is empty or not. If the input is
empty then it will not properly print out an error message and return an error
code.
Differential Revision: https://reviews.llvm.org/D59964
A test/tools/yaml2obj/empty.yaml
M tools/yaml2obj/yaml2obj.cpp
llvm-svn: 357219
Diffstat (limited to 'llvm/tools/yaml2obj/yaml2obj.cpp')
| -rw-r--r-- | llvm/tools/yaml2obj/yaml2obj.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/tools/yaml2obj/yaml2obj.cpp b/llvm/tools/yaml2obj/yaml2obj.cpp index 58e69fd5a5b..ef35458a8f0 100644 --- a/llvm/tools/yaml2obj/yaml2obj.cpp +++ b/llvm/tools/yaml2obj/yaml2obj.cpp @@ -86,7 +86,10 @@ int main(int argc, char **argv) { if (!Buf) return 1; - yaml::Input YIn(Buf.get()->getBuffer()); + StringRef Buffer = Buf.get()->getBuffer(); + if (Buffer.trim().size() == 0) + error("yaml2obj: Error opening '" + Input + "': Empty File."); + yaml::Input YIn(Buffer); int Res = convertYAML(YIn, Out->os()); if (Res == 0) |

