From 34fa8d90ae2f60fae219e4dbeff14c053d2e8eef Mon Sep 17 00:00:00 2001 From: Wei Li Date: Mon, 21 Mar 2016 10:33:56 -0700 Subject: Handle empty objects in IsSameTextObject() and free from warning When both text objects have no items, directly return TRUE; The last if statement moved inside loop to make the intent more obvious and free from warning (msvc warns using potentially uninitialized var itemPer) R=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/1815453002 . --- core/fpdftext/fpdf_text_int.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'core/fpdftext') diff --git a/core/fpdftext/fpdf_text_int.cpp b/core/fpdftext/fpdf_text_int.cpp index 9a2a8c1bde..b6843bae9a 100644 --- a/core/fpdftext/fpdf_text_int.cpp +++ b/core/fpdftext/fpdf_text_int.cpp @@ -1804,7 +1804,12 @@ FX_BOOL CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, if (nPreCount != nCurCount) { return FALSE; } - CPDF_TextObjectItem itemPer, itemCur; + // If both objects have no items, consider them same. + if (!nPreCount) + return TRUE; + + CPDF_TextObjectItem itemPer = {0, 0.0f, 0.0f}; + CPDF_TextObjectItem itemCur = {0, 0.0f, 0.0f}; for (int i = 0; i < nPreCount; i++) { pTextObj2->GetItemInfo(i, &itemPer); pTextObj1->GetItemInfo(i, &itemCur); @@ -1823,6 +1828,7 @@ FX_BOOL CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, } return TRUE; } + FX_BOOL CPDF_TextPage::IsSameAsPreTextObject( CPDF_TextObject* pTextObj, const CPDF_PageObjectList* pObjList, -- cgit v1.2.3