From ac8357b3ec7e1fe4000ebcae5ce65a38bfeb5cb1 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Mon, 28 May 2018 20:06:19 +0000 Subject: Revert 'Remove almost all usages of CFX_FixedBufGrow with std::vector' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a manual revert of the CL at: https://pdfium-review.googlesource.com/c/pdfium/+/32159 The only file manually changed was cpdf_renderstatus.cpp Reason for revert: the bug below shows that sometimes the vector size used is larger than the parameter given to CFX_FixedBufGrow. Thus, we will revert, then add vectors using std::max unless it's clear from the code that the code will never access indices outside. Bug: chromium:847247 Change-Id: Iee54af023c8564824418a7d34a6385b0bc418ff0 Reviewed-on: https://pdfium-review.googlesource.com/33050 Reviewed-by: dsinclair Commit-Queue: Nicolás Peña Moreno --- core/fxge/apple/fx_apple_platform.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'core/fxge') diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index 013be8f414..1801814e66 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -5,8 +5,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include -#include +#include "core/fxcrt/cfx_fixedbufgrow.h" #include "core/fxcrt/fx_system.h" #ifndef _SKIA_SUPPORT_ @@ -57,12 +57,11 @@ bool CGDrawGlyphRun(CGContextRef pContext, if (!pFont->GetPlatformFont()) return false; } - std::vector glyph_indices; - glyph_indices.reserve(nChars); - std::vector glyph_positions(nChars); + CFX_FixedBufGrow glyph_indices(nChars); + CFX_FixedBufGrow glyph_positions(nChars); for (int i = 0; i < nChars; i++) { - glyph_indices.push_back(pCharPos[i].m_ExtGID ? pCharPos[i].m_ExtGID - : pCharPos[i].m_GlyphIndex); + glyph_indices[i] = + pCharPos[i].m_ExtGID ? pCharPos[i].m_ExtGID : pCharPos[i].m_GlyphIndex; if (bNegSize) glyph_positions[i].x = -pCharPos[i].m_Origin.x; else @@ -77,9 +76,9 @@ bool CGDrawGlyphRun(CGContextRef pContext, new_matrix.d = -new_matrix.d; } quartz2d.setGraphicsTextMatrix(pContext, &new_matrix); - return quartz2d.drawGraphicsString( - pContext, pFont->GetPlatformFont(), font_size, glyph_indices.data(), - glyph_positions.data(), nChars, argb, nullptr); + return quartz2d.drawGraphicsString(pContext, pFont->GetPlatformFont(), + font_size, glyph_indices, glyph_positions, + nChars, argb, nullptr); } } // namespace -- cgit v1.2.3