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

Unified Diff: core/fpdfapi/fpdf_page/fpdf_page_parser.cpp

Issue 1998583002: Fix leak in CPDF_StreamContentParser::AddTextObject(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: CollectionSize Created 4 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/fpdfapi/fpdf_page/cpdf_clippathdata.cpp ('k') | core/fpdfapi/fpdf_page/include/cpdf_clippath.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 8c16d8c41f1dc23ab635b519455cada6de745ac4..0374915af422ffbd1c55209cc38aacbeefd8898b 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -813,18 +813,12 @@ void CPDF_StreamContentParser::Handle_EndMarkedContent() {
}
void CPDF_StreamContentParser::Handle_EndText() {
- int count = m_ClipTextList.GetSize();
- if (count == 0) {
+ if (m_ClipTextList.empty())
return;
- }
- if (m_pCurStates->m_TextState.GetObject()->m_TextMode < 4) {
- for (int i = 0; i < count; i++) {
- delete m_ClipTextList.GetAt(i);
- }
- } else {
- m_pCurStates->m_ClipPath.AppendTexts(m_ClipTextList.GetData(), count);
- }
- m_ClipTextList.RemoveAll();
+
+ if (m_pCurStates->m_TextState.GetObject()->m_TextMode >= 4)
+ m_pCurStates->m_ClipPath.AppendTexts(&m_ClipTextList);
+ m_ClipTextList.clear();
}
void CPDF_StreamContentParser::Handle_FillPath() {
@@ -1284,8 +1278,10 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
m_pCurStates->m_TextHorzScale, m_Level);
m_pCurStates->m_TextX += x_advance;
m_pCurStates->m_TextY += y_advance;
- if (textmode > 3)
- m_ClipTextList.Add(pText->Clone());
+ if (textmode > 3) {
+ m_ClipTextList.push_back(
+ std::unique_ptr<CPDF_TextObject>(pText->Clone()));
+ }
m_pObjectHolder->GetPageObjectList()->push_back(std::move(pText));
}
if (pKerning && pKerning[nsegs - 1] != 0) {
@@ -1483,7 +1479,8 @@ void CPDF_StreamContentParser::AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag) {
}
void CPDF_StreamContentParser::AddPathObject(int FillType, FX_BOOL bStroke) {
- int PathPointCount = m_PathPointCount, PathClipType = m_PathClipType;
+ int PathPointCount = m_PathPointCount;
+ uint8_t PathClipType = m_PathClipType;
m_PathPointCount = 0;
m_PathClipType = 0;
if (PathPointCount <= 1) {
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_clippathdata.cpp ('k') | core/fpdfapi/fpdf_page/include/cpdf_clippath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698