]> granicus.if.org Git - llvm/commit
[obj2yaml] - Stop triggering UB when dumping corrupted strings.
authorGeorge Rimar <grimar@accesssoftek.com>
Mon, 21 Oct 2019 10:38:03 +0000 (10:38 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Mon, 21 Oct 2019 10:38:03 +0000 (10:38 +0000)
commit63b9649758d269176eda84f153cec6738d2edc4a
treebf9057e378216e7ef5eef75227a5c2f65e199c54
parent7fc698b06acd483d3ad8ee5a64703fd67e021b1c
[obj2yaml] - Stop triggering UB when dumping corrupted strings.

We have a following code to find quote type:

if (isspace(S.front()) || isspace(S.back()))
...

Problem is that:

"int isspace( int ch ): The behavior is undefined if the value of
ch is not representable as unsigned char and is not equal to EOF."
(https://en.cppreference.com/w/cpp/string/byte/isspace)

This patch shows how this UB can be triggered and fixes an issue.

Differential revision: https://reviews.llvm.org/D69160

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375404 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/YAMLTraits.h
test/tools/obj2yaml/invalid-section-name.yaml [new file with mode: 0644]