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

Unified Diff: core/fpdftext/fpdf_text_int.cpp

Issue 1815453002: Handle empty objects in IsSameTextObject() and free from warning (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdftext/fpdf_text_int.cpp
diff --git a/core/fpdftext/fpdf_text_int.cpp b/core/fpdftext/fpdf_text_int.cpp
index be01648d4574d8eee30d702f8bf238d61e860730..2aaa1370da141b50efb7ad9eecf6dc4b421f4d7e 100644
--- a/core/fpdftext/fpdf_text_int.cpp
+++ b/core/fpdftext/fpdf_text_int.cpp
@@ -1802,7 +1802,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);
@@ -1821,6 +1826,7 @@ FX_BOOL CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1,
}
return TRUE;
}
+
FX_BOOL CPDF_TextPage::IsSameAsPreTextObject(
CPDF_TextObject* pTextObj,
const CPDF_PageObjectList* pObjList,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698