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

Side by Side Diff: core/fpdfapi/fpdf_font/fpdf_font_cid.cpp

Issue 2366143002: Fix memory leak in cmap parsing (Closed)
Patch Set: Created 4 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 "core/fpdfapi/fpdf_font/font_int.h" 7 #include "core/fpdfapi/fpdf_font/font_int.h"
8 8
9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" 9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
10 #include "core/fpdfapi/fpdf_font/ttgsubtable.h" 10 #include "core/fpdfapi/fpdf_font/ttgsubtable.h"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 m_Status = 0; 406 m_Status = 0;
407 } else if (m_Status == 6) { 407 } else if (m_Status == 6) {
408 m_pCMap->m_bVertical = CMap_GetCode(word) != 0; 408 m_pCMap->m_bVertical = CMap_GetCode(word) != 0;
409 m_Status = 0; 409 m_Status = 0;
410 } else if (m_Status == 7) { 410 } else if (m_Status == 7) {
411 if (word == "endcodespacerange") { 411 if (word == "endcodespacerange") {
412 int nSegs = m_CodeRanges.GetSize(); 412 int nSegs = m_CodeRanges.GetSize();
413 if (nSegs > 1) { 413 if (nSegs > 1) {
414 m_pCMap->m_CodingScheme = CPDF_CMap::MixedFourBytes; 414 m_pCMap->m_CodingScheme = CPDF_CMap::MixedFourBytes;
415 m_pCMap->m_nCodeRanges = nSegs; 415 m_pCMap->m_nCodeRanges = nSegs;
416 FX_Free(m_pCMap->m_pLeadingBytes);
416 m_pCMap->m_pLeadingBytes = 417 m_pCMap->m_pLeadingBytes =
417 FX_Alloc2D(uint8_t, nSegs, sizeof(CMap_CodeRange)); 418 FX_Alloc2D(uint8_t, nSegs, sizeof(CMap_CodeRange));
418 FXSYS_memcpy(m_pCMap->m_pLeadingBytes, m_CodeRanges.GetData(), 419 FXSYS_memcpy(m_pCMap->m_pLeadingBytes, m_CodeRanges.GetData(),
419 nSegs * sizeof(CMap_CodeRange)); 420 nSegs * sizeof(CMap_CodeRange));
420 } else if (nSegs == 1) { 421 } else if (nSegs == 1) {
421 m_pCMap->m_CodingScheme = (m_CodeRanges[0].m_CharSize == 2) 422 m_pCMap->m_CodingScheme = (m_CodeRanges[0].m_CharSize == 2)
422 ? CPDF_CMap::TwoBytes 423 ? CPDF_CMap::TwoBytes
423 : CPDF_CMap::OneByte; 424 : CPDF_CMap::OneByte;
424 } 425 }
425 m_Status = 0; 426 m_Status = 0;
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 m_EmbeddedCount = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; 781 m_EmbeddedCount = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count;
781 } 782 }
782 783
783 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) { 784 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) {
784 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { 785 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) {
785 if (ordering == g_CharsetNames[charset]) 786 if (ordering == g_CharsetNames[charset])
786 return CIDSetFromSizeT(charset); 787 return CIDSetFromSizeT(charset);
787 } 788 }
788 return CIDSET_UNKNOWN; 789 return CIDSET_UNKNOWN;
789 } 790 }
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