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

Side by Side Diff: core/src/fxge/ge/fx_ge_fontmap.cpp

Issue 1763493003: Check that the names buffer is not empty before passing to GetNameFromTT. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 if (!FXSYS_fread(buffer, 12, 1, pFile)) { 1414 if (!FXSYS_fread(buffer, 12, 1, pFile)) {
1415 return; 1415 return;
1416 } 1416 }
1417 FX_DWORD nTables = GET_TT_SHORT(buffer + 4); 1417 FX_DWORD nTables = GET_TT_SHORT(buffer + 4);
1418 CFX_ByteString tables = FPDF_ReadStringFromFile(pFile, nTables * 16); 1418 CFX_ByteString tables = FPDF_ReadStringFromFile(pFile, nTables * 16);
1419 if (tables.IsEmpty()) { 1419 if (tables.IsEmpty()) {
1420 return; 1420 return;
1421 } 1421 }
1422 CFX_ByteString names = 1422 CFX_ByteString names =
1423 FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65); 1423 FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65);
1424 if (names.IsEmpty()) {
1425 return;
1426 }
1424 CFX_ByteString facename = GetNameFromTT(names, 1); 1427 CFX_ByteString facename = GetNameFromTT(names, 1);
1425 CFX_ByteString style = GetNameFromTT(names, 2); 1428 CFX_ByteString style = GetNameFromTT(names, 2);
1426 if (style != "Regular") { 1429 if (style != "Regular") {
1427 facename += " " + style; 1430 facename += " " + style;
1428 } 1431 }
1429 if (pdfium::ContainsKey(m_FontList, facename)) 1432 if (pdfium::ContainsKey(m_FontList, facename))
1430 return; 1433 return;
1431 1434
1432 CFX_FontFaceInfo* pInfo = 1435 CFX_FontFaceInfo* pInfo =
1433 new CFX_FontFaceInfo(path, facename, tables, offset, filesize); 1436 new CFX_FontFaceInfo(path, facename, tables, offset, filesize);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 int PDF_GetStandardFontName(CFX_ByteString* name) { 1596 int PDF_GetStandardFontName(CFX_ByteString* name) {
1594 AltFontName* found = static_cast<AltFontName*>( 1597 AltFontName* found = static_cast<AltFontName*>(
1595 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), 1598 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames),
1596 sizeof(AltFontName), CompareString)); 1599 sizeof(AltFontName), CompareString));
1597 if (!found) 1600 if (!found)
1598 return -1; 1601 return -1;
1599 1602
1600 *name = g_Base14FontNames[found->m_Index]; 1603 *name = g_Base14FontNames[found->m_Index];
1601 return found->m_Index; 1604 return found->m_Index;
1602 } 1605 }
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