summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-07-20 23:41:26 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-07-21 18:38:48 +0000
commitd0856ba49c2bdcb288e0976d2162db17210a66df (patch)
tree48b8620b823fccaca15a6149dbb130cdc417bcbc /core
parent926c65a49ca4769274022678e53144fe335c70b5 (diff)
downloadpdfium-d0856ba49c2bdcb288e0976d2162db17210a66df.tar.xz
Fix nits from commit 67ccef7.chromium/3164
Change-Id: I24b191ecfe8b65a7d0ddc4958dc117de9ed9ae83 Reviewed-on: https://pdfium-review.googlesource.com/8630 Reviewed-by: Jane Liu <janeliulwq@google.com> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfdoc/cpdf_nametree.cpp16
-rw-r--r--core/fpdfdoc/cpdf_nametree_unittest.cpp5
2 files changed, 11 insertions, 10 deletions
diff --git a/core/fpdfdoc/cpdf_nametree.cpp b/core/fpdfdoc/cpdf_nametree.cpp
index 04cb1b9e40..f30a27c681 100644
--- a/core/fpdfdoc/cpdf_nametree.cpp
+++ b/core/fpdfdoc/cpdf_nametree.cpp
@@ -43,14 +43,14 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
for (size_t i = 0; i < dwCount; i++) {
CFX_WideString csValue = pNames->GetUnicodeTextAt(i * 2);
int32_t iCompare = csValue.Compare(csName);
- if (iCompare <= 0) {
- if (ppFind)
- *ppFind = pNames;
- if (iCompare < 0)
- continue;
- } else {
+ if (iCompare > 0)
break;
- }
+
+ if (ppFind)
+ *ppFind = pNames;
+ if (iCompare < 0)
+ continue;
+
nIndex += i;
return pNames->GetDirectObjectAt(i * 2 + 1);
}
@@ -170,7 +170,7 @@ int CPDF_NameTree::GetIndex(const CFX_WideString& csName) const {
CPDF_Object* CPDF_NameTree::LookupValueAndName(int nIndex,
CFX_WideString* csName) const {
- *csName = CFX_WideString();
+ csName->clear();
if (!m_pRoot)
return nullptr;
diff --git a/core/fpdfdoc/cpdf_nametree_unittest.cpp b/core/fpdfdoc/cpdf_nametree_unittest.cpp
index 28af9e078d..bffb496843 100644
--- a/core/fpdfdoc/cpdf_nametree_unittest.cpp
+++ b/core/fpdfdoc/cpdf_nametree_unittest.cpp
@@ -16,8 +16,9 @@ TEST(cpdf_nametree, GetUnicodeNameWithBOM) {
// Add the key "1" (with BOM) and value 100 into the array.
std::ostringstream buf;
- buf << static_cast<unsigned char>(254) << static_cast<unsigned char>(255)
- << static_cast<unsigned char>(0) << static_cast<unsigned char>(49);
+ constexpr char kData[] = "\xFE\xFF\x00\x31";
+ for (size_t i = 0; i < sizeof(kData); ++i)
+ buf.put(kData[i]);
pNames->AddNew<CPDF_String>(CFX_ByteString(buf), true);
pNames->AddNew<CPDF_Number>(100);