From: Zachary Turner Date: Sun, 8 Feb 2015 18:08:51 +0000 (+0000) Subject: Make UTF8->UTF16 conversion null terminate output on empty input. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3afd6d07341d725685f7e612bf457de7d13a14f3;p=oota-llvm.git Make UTF8->UTF16 conversion null terminate output on empty input. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228527 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/ConvertUTFWrapper.cpp b/lib/Support/ConvertUTFWrapper.cpp index 4feff01b08e..1bbef233b82 100644 --- a/lib/Support/ConvertUTFWrapper.cpp +++ b/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(SrcUTF8.begin()); const UTF8 *SrcEnd = reinterpret_cast(SrcUTF8.end());