From b6db208773e94b9d25f7dbd740859adbb8a60fdf Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Fri, 14 Jul 2017 10:00:21 -0400 Subject: More unique_ptrs in JBIG2 code part 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL makes HDPATS in CJBig2_PatternDict be a vector of unique_ptr. Change-Id: Ib23aed6323d4a988b2eedc4bfe95f2098d32c188 Reviewed-on: https://pdfium-review.googlesource.com/7871 Commit-Queue: Nicolás Peña Reviewed-by: Tom Sepez --- core/fxcodec/jbig2/JBig2_HtrdProc.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'core/fxcodec/jbig2/JBig2_HtrdProc.cpp') diff --git a/core/fxcodec/jbig2/JBig2_HtrdProc.cpp b/core/fxcodec/jbig2/JBig2_HtrdProc.cpp index f17e818588..a7de28607e 100644 --- a/core/fxcodec/jbig2/JBig2_HtrdProc.cpp +++ b/core/fxcodec/jbig2/JBig2_HtrdProc.cpp @@ -6,6 +6,8 @@ #include "core/fxcodec/jbig2/JBig2_HtrdProc.h" +#include + #include "core/fxcodec/jbig2/JBig2_GsidProc.h" #include "core/fxcrt/fx_basic.h" #include "third_party/base/ptr_util.h" @@ -56,11 +58,8 @@ std::unique_ptr CJBig2_HTRDProc::decode_Arith( for (ng = 0; ng < HGW; ng++) { x = (HGX + mg * HRY + ng * HRX) >> 8; y = (HGY + mg * HRX - ng * HRY) >> 8; - uint32_t pat_index = GI[mg * HGW + ng]; - if (pat_index >= HNUMPATS) { - pat_index = HNUMPATS - 1; - } - HTREG->composeFrom(x, y, HPATS[pat_index], HCOMBOP); + uint32_t pat_index = std::min(GI[mg * HGW + ng], HNUMPATS - 1); + HTREG->composeFrom(x, y, (*HPATS)[pat_index].get(), HCOMBOP); } } FX_Free(GI); @@ -92,11 +91,8 @@ std::unique_ptr CJBig2_HTRDProc::decode_MMR( for (ng = 0; ng < HGW; ng++) { x = (HGX + mg * HRY + ng * HRX) >> 8; y = (HGY + mg * HRX - ng * HRY) >> 8; - uint32_t pat_index = GI[mg * HGW + ng]; - if (pat_index >= HNUMPATS) { - pat_index = HNUMPATS - 1; - } - HTREG->composeFrom(x, y, HPATS[pat_index], HCOMBOP); + uint32_t pat_index = std::min(GI[mg * HGW + ng], HNUMPATS - 1); + HTREG->composeFrom(x, y, (*HPATS)[pat_index].get(), HCOMBOP); } } FX_Free(GI); -- cgit v1.2.3