summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-02-08 18:08:51 +0000
committerZachary Turner <zturner@google.com>2015-02-08 18:08:51 +0000
commitafdff425d78ac5893ed40aac37930fbd7fa2dff1 (patch)
tree63116b89e588987cbff3a42dd041f7a9892e074b
parentd11b01362305c1e8b1afadd27ec1289536ba9a5a (diff)
downloadbcm5719-llvm-afdff425d78ac5893ed40aac37930fbd7fa2dff1.tar.gz
bcm5719-llvm-afdff425d78ac5893ed40aac37930fbd7fa2dff1.zip
Make UTF8->UTF16 conversion null terminate output on empty input.
llvm-svn: 228527
-rw-r--r--llvm/lib/Support/ConvertUTFWrapper.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp
index 4feff01b08e..1bbef233b82 100644
--- a/llvm/lib/Support/ConvertUTFWrapper.cpp
+++ b/llvm/lib/Support/ConvertUTFWrapper.cpp
@@ -135,8 +135,11 @@ bool convertUTF8ToUTF16String(StringRef SrcUTF8,
assert(DstUTF16.empty());
// Avoid OOB by returning early on empty input.
- if (SrcUTF8.empty())
+ if (SrcUTF8.empty()) {
+ DstUTF16.push_back(0);
+ DstUTF16.pop_back();
return true;
+ }
const UTF8 *Src = reinterpret_cast<const UTF8 *>(SrcUTF8.begin());
const UTF8 *SrcEnd = reinterpret_cast<const UTF8 *>(SrcUTF8.end());
OpenPOWER on IntegriCloud