From 39fa751f84bc226c22d65c2fc5e7d3615dfe5ddb Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 21 Aug 2017 15:20:49 -0700 Subject: Avoid an ASSERT failure in CFX_SeekableStreamProxy. BUG=chromium:718503 Change-Id: I6ff332c2ab5320d1b5f39a9aa1564e7e3e243cbe Reviewed-on: https://pdfium-review.googlesource.com/11570 Commit-Queue: dsinclair Reviewed-by: dsinclair --- core/fxcrt/cfx_seekablestreamproxy.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'core/fxcrt') 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 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(pBuffer); wchar_t* pDst = static_cast(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(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_ -- cgit v1.2.3