commit | de03dff28f3562babc9e53d792e445fa3e1e9d0c | [log] [tgz] |
---|---|---|
author | Tom Sepez <tsepez@chromium.org> | Tue Mar 19 16:50:54 2019 +0000 |
committer | Chromium commit bot <commit-bot@chromium.org> | Tue Mar 19 16:50:54 2019 +0000 |
tree | 41790fa6bf835b37812c28741524b1a639b92fc0 | |
parent | 3d3dcdff38a692c7dfc0a064e37cdf44c0fa34a7 [diff] |
Fix self-intersecting copy in UTF16ToWchar() Broken at https://pdfium-review.googlesource.com/c/pdfium/+/12210 Apply a simple fix before converting to spans. Change-Id: I78c822cade18b043c8973f39c4a9dacd30238486 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/52011 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp index 9f35cb0..5884bca 100644 --- a/core/fxcrt/cfx_seekablestreamproxy.cpp +++ b/core/fxcrt/cfx_seekablestreamproxy.cpp
@@ -83,8 +83,10 @@ uint16_t* pSrc = static_cast<uint16_t*>(pBuffer); wchar_t* pDst = static_cast<wchar_t*>(pBuffer); - for (size_t i = 0; i < iLength; i++) - pDst[i] = static_cast<wchar_t>(pSrc[i]); + + // Peform self-intersecting copy in reverse order. + for (size_t i = iLength; i > 0; --i) + pDst[i - 1] = static_cast<wchar_t>(pSrc[i - 1]); } void SwapByteOrder(wchar_t* pStr, size_t iLength) {