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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1536113002: Fix a memory leak in CPDF_DataAvail::CheckHintTables (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix Created 5 years 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 "parser_int.h" 7 #include "parser_int.h"
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 3582 matching lines...) Expand 10 before | Expand all | Expand 10 after
3593 if (szHSStart < 0 || szHSLength <= 0) { 3593 if (szHSStart < 0 || szHSLength <= 0) {
3594 m_docStatus = PDF_DATAAVAIL_ERROR; 3594 m_docStatus = PDF_DATAAVAIL_ERROR;
3595 return FALSE; 3595 return FALSE;
3596 } 3596 }
3597 if (!IsDataAvail(szHSStart, szHSLength, pHints)) { 3597 if (!IsDataAvail(szHSStart, szHSLength, pHints)) {
3598 return FALSE; 3598 return FALSE;
3599 } 3599 }
3600 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset); 3600 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset);
3601 nonstd::unique_ptr<CPDF_HintTables> pHintTables( 3601 nonstd::unique_ptr<CPDF_HintTables> pHintTables(
3602 new CPDF_HintTables(this, pDict)); 3602 new CPDF_HintTables(this, pDict));
3603 CPDF_Stream* pHintStream = (CPDF_Stream*)ParseIndirectObjectAt(szHSStart, 0); 3603 nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pHintStream(
3604 ParseIndirectObjectAt(szHSStart, 0));
3605
Lei Zhang 2015/12/18 22:09:12 What do you think of this? nonstd::unique_ptr<CPD
Oliver Chang 2015/12/18 22:18:30 Thanks for the suggestion. I've simplified this a
3604 if (pHintStream && pHintStream->GetType() == PDFOBJ_STREAM && 3606 if (pHintStream && pHintStream->GetType() == PDFOBJ_STREAM &&
3605 pHintTables->LoadHintStream(pHintStream)) 3607 pHintTables->LoadHintStream(pHintStream->AsStream()))
3606 m_pHintTables.reset(pHintTables.release()); 3608 m_pHintTables.reset(pHintTables.release());
3607 3609
3608 m_docStatus = PDF_DATAAVAIL_DONE; 3610 m_docStatus = PDF_DATAAVAIL_DONE;
3609 return TRUE; 3611 return TRUE;
3610 } 3612 }
3611 CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt( 3613 CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt(
3612 FX_FILESIZE pos, 3614 FX_FILESIZE pos,
3613 FX_DWORD objnum, 3615 FX_DWORD objnum,
3614 CPDF_IndirectObjects* pObjList) { 3616 CPDF_IndirectObjects* pObjList) {
3615 FX_FILESIZE SavedPos = m_syntaxParser.SavePos(); 3617 FX_FILESIZE SavedPos = m_syntaxParser.SavePos();
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
4983 if (!m_pLinearizedDict) 4985 if (!m_pLinearizedDict)
4984 return -1; 4986 return -1;
4985 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); 4987 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H");
4986 if (!pRange) 4988 if (!pRange)
4987 return -1; 4989 return -1;
4988 CPDF_Object* pStreamLen = pRange->GetElementValue(1); 4990 CPDF_Object* pStreamLen = pRange->GetElementValue(1);
4989 if (!pStreamLen) 4991 if (!pStreamLen)
4990 return -1; 4992 return -1;
4991 return pStreamLen->GetInteger(); 4993 return pStreamLen->GetInteger();
4992 } 4994 }
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