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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp

Issue 652063002: Don't leave dangling pointer to out-of-scope local in CPDF_StreamContentParser::Parse. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use CPDF_ prefix. Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../include/fpdfapi/fpdf_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 #include "pageint.h" 10 #include "pageint.h"
(...skipping 13 matching lines...) Expand all
24 return FALSE; 24 return FALSE;
25 } 25 }
26 FX_BYTE ch; 26 FX_BYTE ch;
27 while((ch = *op++)) { 27 while((ch = *op++)) {
28 if(_PDF_OpCharType[ch] == 'I') { 28 if(_PDF_OpCharType[ch] == 'I') {
29 return TRUE; 29 return TRUE;
30 } 30 }
31 } 31 }
32 return FALSE; 32 return FALSE;
33 } 33 }
34 class CPDF_StreamParserAutoClearer {
35 public:
36 CPDF_StreamParserAutoClearer(CPDF_StreamParser** scoped_variable, CPDF_Strea mParser* new_parser)
37 : scoped_variable_(scoped_variable) {
38 *scoped_variable_ = new_parser;
jun_fang 2014/10/14 20:54:08 nit: shall we check whether scoped_variable_ is no
39 }
40 ~CPDF_StreamParserAutoClearer() { *scoped_variable_ = NULL; }
41 private:
42 CPDF_StreamParser** scoped_variable_;
43 };
34 FX_DWORD CPDF_StreamContentParser::Parse(FX_LPCBYTE pData, FX_DWORD dwSize, FX_D WORD max_cost) 44 FX_DWORD CPDF_StreamContentParser::Parse(FX_LPCBYTE pData, FX_DWORD dwSize, FX_D WORD max_cost)
35 { 45 {
36 if (m_Level > _FPDF_MAX_FORM_LEVEL_) { 46 if (m_Level > _FPDF_MAX_FORM_LEVEL_) {
37 return dwSize; 47 return dwSize;
38 } 48 }
39 FX_DWORD InitObjCount = m_pObjectList->CountObjects(); 49 FX_DWORD InitObjCount = m_pObjectList->CountObjects();
40 CPDF_StreamParser syntax(pData, dwSize); 50 CPDF_StreamParser syntax(pData, dwSize);
41 m_pSyntax = &syntax; 51 CPDF_StreamParserAutoClearer auto_clearer(&m_pSyntax, &syntax);
42 m_CompatCount = 0; 52 m_CompatCount = 0;
43 while (1) { 53 while (1) {
44 FX_DWORD cost = m_pObjectList->CountObjects() - InitObjCount; 54 FX_DWORD cost = m_pObjectList->CountObjects() - InitObjCount;
45 if (max_cost && cost >= max_cost) { 55 if (max_cost && cost >= max_cost) {
46 break; 56 break;
47 } 57 }
48 switch (syntax.ParseNextElement()) { 58 switch (syntax.ParseNextElement()) {
49 case CPDF_StreamParser::EndOfData: 59 case CPDF_StreamParser::EndOfData:
50 return m_pSyntax->GetPos(); 60 return m_pSyntax->GetPos();
51 case CPDF_StreamParser::Keyword: 61 case CPDF_StreamParser::Keyword:
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 return 100; 1146 return 100;
1137 } 1147 }
1138 if (m_InternalStage == PAGEPARSE_STAGE_GETCONTENT) { 1148 if (m_InternalStage == PAGEPARSE_STAGE_GETCONTENT) {
1139 return 10; 1149 return 10;
1140 } 1150 }
1141 if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) { 1151 if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) {
1142 return 90; 1152 return 90;
1143 } 1153 }
1144 return 10 + 80 * m_CurrentOffset / m_Size; 1154 return 10 + 80 * m_CurrentOffset / m_Size;
1145 } 1155 }
OLDNEW
« 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