Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: core/src/fxcrt/fx_basic_wstring.cpp

Issue 1141763002: Fix comparison of CFX_ByteString and CFX_WideString against empty literals. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Cover a few more cases. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring_unittest.cpp ('k') | core/src/fxcrt/fx_basic_wstring_unittest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_basic_wstring.cpp
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index ce3166b196ecbbbfb91d3b87bd0aee611e3c1a96..0511b847e3252f1634d533ec72ee1ac486f70f54 100644
--- a/core/src/fxcrt/fx_basic_wstring.cpp
+++ b/core/src/fxcrt/fx_basic_wstring.cpp
@@ -206,10 +206,10 @@ const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& string)
bool CFX_WideString::Equal(const wchar_t* ptr) const
{
if (!m_pData) {
- return !ptr;
+ return !ptr || ptr[0] == L'\0';
}
if (!ptr) {
- return false;
+ return m_pData->m_nDataLength == 0;
}
return wcslen(ptr) == m_pData->m_nDataLength &&
wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
@@ -224,10 +224,10 @@ bool CFX_WideString::Equal(const CFX_WideStringC& str) const
}
bool CFX_WideString::Equal(const CFX_WideString& other) const
{
- if (!m_pData) {
+ if (IsEmpty()) {
return other.IsEmpty();
}
- if (!other.m_pData) {
+ if (other.IsEmpty()) {
return false;
}
return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring_unittest.cpp ('k') | core/src/fxcrt/fx_basic_wstring_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698