]> granicus.if.org Git - llvm/commit
YAMLIO: Fix serialization of strings with embedded nuls
authorPavel Labath <pavel@labath.sk>
Thu, 11 Apr 2019 14:57:34 +0000 (14:57 +0000)
committerPavel Labath <pavel@labath.sk>
Thu, 11 Apr 2019 14:57:34 +0000 (14:57 +0000)
commita5a6353ba4f2982ec099639482c5ba0776d825dd
tree5351ba7c815244718cccef21a55d5542f843d16b
parentd0586349ae5489f04f70ea1dbab4f1f9d8183c95
YAMLIO: Fix serialization of strings with embedded nuls

Summary:
A bug/typo in Output::scalarString caused us to round-trip a StringRef
through a const char *. This meant that any strings with embedded nuls
were unintentionally cut short at the first such character. (It also
could have caused accidental buffer overruns, but it seems that all
StringRefs coming into this functions were formed from null-terminated
strings.)

This patch fixes the bug and adds an appropriate test.

Reviewers: sammccall, jhenderson

Subscribers: kristina, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60505

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358176 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/YAMLTraits.cpp
unittests/Support/YAMLIOTest.cpp