[llvm] r228527 - Make UTF8->UTF16 conversion null terminate output on empty input.
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Feb 9 10:45:24 PST 2015
Testcase?
> On 2015-Feb-08, at 10:08, Zachary Turner <zturner at google.com> wrote:
>
> Author: zturner
> Date: Sun Feb 8 12:08:51 2015
> New Revision: 228527
>
> URL: http://llvm.org/viewvc/llvm-project?rev=228527&view=rev
> Log:
> Make UTF8->UTF16 conversion null terminate output on empty input.
>
> Modified:
> llvm/trunk/lib/Support/ConvertUTFWrapper.cpp
>
> Modified: llvm/trunk/lib/Support/ConvertUTFWrapper.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ConvertUTFWrapper.cpp?rev=228527&r1=228526&r2=228527&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/ConvertUTFWrapper.cpp (original)
> +++ llvm/trunk/lib/Support/ConvertUTFWrapper.cpp Sun Feb 8 12:08:51 2015
> @@ -135,8 +135,11 @@ bool convertUTF8ToUTF16String(StringRef
> 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());
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list