summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_seekablestreamproxy.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-08-21 15:20:49 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-08-22 13:06:33 +0000
commit39fa751f84bc226c22d65c2fc5e7d3615dfe5ddb (patch)
tree4598a3d8b57e4f04814fd5b0b8caed1cd8313796 /core/fxcrt/cfx_seekablestreamproxy.cpp
parentbde6f35d285b0415cdcaf92e58fbe276bc499255 (diff)
downloadpdfium-39fa751f84bc226c22d65c2fc5e7d3615dfe5ddb.tar.xz
Avoid an ASSERT failure in CFX_SeekableStreamProxy.
BUG=chromium:718503 Change-Id: I6ff332c2ab5320d1b5f39a9aa1564e7e3e243cbe Reviewed-on: https://pdfium-review.googlesource.com/11570 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_seekablestreamproxy.cpp')
-rw-r--r--core/fxcrt/cfx_seekablestreamproxy.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp
index 9b44f95d13..6906e1c84d 100644
--- a/core/fxcrt/cfx_seekablestreamproxy.cpp
+++ b/core/fxcrt/cfx_seekablestreamproxy.cpp
@@ -92,10 +92,9 @@ std::pair<FX_STRSIZE, FX_STRSIZE> UTF8Decode(const char* pSrc,
}
void UTF16ToWChar(void* pBuffer, FX_STRSIZE iLength) {
- ASSERT(pBuffer && iLength > 0);
-
- if (sizeof(wchar_t) == 2)
- return;
+ ASSERT(pBuffer);
+ ASSERT(iLength > 0);
+ ASSERT(sizeof(wchar_t) > 2);
uint16_t* pSrc = static_cast<uint16_t*>(pBuffer);
wchar_t* pDst = static_cast<wchar_t*>(pBuffer);
@@ -242,7 +241,8 @@ FX_STRSIZE CFX_SeekableStreamProxy::ReadData(uint8_t* pBuffer,
FX_STRSIZE CFX_SeekableStreamProxy::ReadString(wchar_t* pStr,
FX_STRSIZE iMaxLength,
bool* bEOS) {
- ASSERT(pStr && iMaxLength > 0);
+ ASSERT(pStr);
+ ASSERT(iMaxLength > 0);
if (m_IsWriteStream)
return -1;
@@ -252,7 +252,7 @@ FX_STRSIZE CFX_SeekableStreamProxy::ReadString(wchar_t* pStr,
FX_FILESIZE iBytes = iMaxLength * 2;
FX_STRSIZE iLen = ReadData(reinterpret_cast<uint8_t*>(pStr), iBytes);
iMaxLength = iLen / 2;
- if (sizeof(wchar_t) > 2)
+ if (sizeof(wchar_t) > 2 && iMaxLength > 0)
UTF16ToWChar(pStr, iMaxLength);
#if _FX_ENDIAN_ == _FX_BIG_ENDIAN_