summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-08-30 16:22:54 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-31 16:21:28 +0000
commitfd42fc91f4fb4a2d85c8434e6ac2ec5d0ff6977b (patch)
tree2399834ade358176de19223686ea5f91a9c9bbb0 /core
parentaf59cf16b40b6243a2194ced3e5f476ec655edb3 (diff)
downloadpdfium-fd42fc91f4fb4a2d85c8434e6ac2ec5d0ff6977b.tar.xz
Use vector instead of pointer in CJBig2_Segment
Change-Id: Ic54e0491d9b33a06b5f85963f8127bfa4263f4d6 Reviewed-on: https://pdfium-review.googlesource.com/12450 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.cpp30
-rw-r--r--core/fxcodec/jbig2/JBig2_Segment.cpp25
-rw-r--r--core/fxcodec/jbig2/JBig2_Segment.h3
3 files changed, 28 insertions, 30 deletions
diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp
index a1f6cc6bca..363be2fc31 100644
--- a/core/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/fxcodec/jbig2/JBig2_Context.cpp
@@ -238,7 +238,7 @@ CJBig2_Segment* CJBig2_Context::findReferredSegmentByTypeAndIndex(
int32_t count = 0;
for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) {
CJBig2_Segment* pSeg =
- findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]);
+ findSegmentByNumber(pSegment->m_Referred_to_segment_numbers[i]);
if (pSeg && pSeg->m_cFlags.s.type == cType) {
if (count == nIndex)
return pSeg;
@@ -278,31 +278,31 @@ int32_t CJBig2_Context::parseSegmentHeader(CJBig2_Segment* pSegment) {
pSegment->m_dwNumber > 65536 ? 4 : pSegment->m_dwNumber > 256 ? 2 : 1;
uint8_t cPSize = pSegment->m_cFlags.s.page_association_size ? 4 : 1;
if (pSegment->m_nReferred_to_segment_count) {
- pSegment->m_pReferred_to_segment_numbers =
- FX_Alloc(uint32_t, pSegment->m_nReferred_to_segment_count);
+ pSegment->m_Referred_to_segment_numbers.resize(
+ pSegment->m_nReferred_to_segment_count);
for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) {
switch (cSSize) {
case 1:
if (m_pStream->read1Byte(&cTemp) != 0)
return JBIG2_ERROR_TOO_SHORT;
- pSegment->m_pReferred_to_segment_numbers[i] = cTemp;
+ pSegment->m_Referred_to_segment_numbers[i] = cTemp;
break;
case 2:
uint16_t wTemp;
if (m_pStream->readShortInteger(&wTemp) != 0)
return JBIG2_ERROR_TOO_SHORT;
- pSegment->m_pReferred_to_segment_numbers[i] = wTemp;
+ pSegment->m_Referred_to_segment_numbers[i] = wTemp;
break;
case 4:
if (m_pStream->readInteger(&dwTemp) != 0)
return JBIG2_ERROR_TOO_SHORT;
- pSegment->m_pReferred_to_segment_numbers[i] = dwTemp;
+ pSegment->m_Referred_to_segment_numbers[i] = dwTemp;
break;
}
- if (pSegment->m_pReferred_to_segment_numbers[i] >= pSegment->m_dwNumber)
+ if (pSegment->m_Referred_to_segment_numbers[i] >= pSegment->m_dwNumber)
return JBIG2_ERROR_TOO_SHORT;
}
}
@@ -457,14 +457,14 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment) {
return JBIG2_ERROR_LIMIT;
}
for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) {
- if (!findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]))
+ if (!findSegmentByNumber(pSegment->m_Referred_to_segment_numbers[i]))
return JBIG2_ERROR_FATAL;
}
CJBig2_Segment* pLRSeg = nullptr;
pSymbolDictDecoder->SDNUMINSYMS = 0;
for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) {
CJBig2_Segment* pSeg =
- findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]);
+ findSegmentByNumber(pSegment->m_Referred_to_segment_numbers[i]);
if (pSeg->m_cFlags.s.type == 0) {
pSymbolDictDecoder->SDNUMINSYMS += pSeg->m_SymbolDict->NumImages();
pLRSeg = pSeg;
@@ -477,7 +477,7 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment) {
uint32_t dwTemp = 0;
for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) {
CJBig2_Segment* pSeg =
- findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]);
+ findSegmentByNumber(pSegment->m_Referred_to_segment_numbers[i]);
if (pSeg->m_cFlags.s.type == 0) {
const CJBig2_SymbolDict& dict = *pSeg->m_SymbolDict.get();
for (size_t j = 0; j < dict.NumImages(); ++j)
@@ -693,14 +693,14 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
return JBIG2_ERROR_TOO_SHORT;
for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) {
- if (!findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]))
+ if (!findSegmentByNumber(pSegment->m_Referred_to_segment_numbers[i]))
return JBIG2_ERROR_FATAL;
}
pTRD->SBNUMSYMS = 0;
for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) {
CJBig2_Segment* pSeg =
- findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]);
+ findSegmentByNumber(pSegment->m_Referred_to_segment_numbers[i]);
if (pSeg->m_cFlags.s.type == 0) {
pTRD->SBNUMSYMS += pSeg->m_SymbolDict->NumImages();
}
@@ -712,7 +712,7 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
dwTemp = 0;
for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) {
CJBig2_Segment* pSeg =
- findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]);
+ findSegmentByNumber(pSegment->m_Referred_to_segment_numbers[i]);
if (pSeg->m_cFlags.s.type == 0) {
const CJBig2_SymbolDict& dict = *pSeg->m_SymbolDict.get();
for (size_t j = 0; j < dict.NumImages(); ++j)
@@ -1002,7 +1002,7 @@ int32_t CJBig2_Context::parseHalftoneRegion(CJBig2_Segment* pSegment,
return JBIG2_ERROR_FATAL;
CJBig2_Segment* pSeg =
- findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[0]);
+ findSegmentByNumber(pSegment->m_Referred_to_segment_numbers[0]);
if (!pSeg || (pSeg->m_cFlags.s.type != 16))
return JBIG2_ERROR_FATAL;
@@ -1170,7 +1170,7 @@ int32_t CJBig2_Context::parseGenericRefinementRegion(CJBig2_Segment* pSegment) {
if (pSegment->m_nReferred_to_segment_count > 0) {
int32_t i;
for (i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) {
- pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[0]);
+ pSeg = findSegmentByNumber(pSegment->m_Referred_to_segment_numbers[0]);
if (!pSeg)
return JBIG2_ERROR_FATAL;
diff --git a/core/fxcodec/jbig2/JBig2_Segment.cpp b/core/fxcodec/jbig2/JBig2_Segment.cpp
index 886989abd8..58be8103d7 100644
--- a/core/fxcodec/jbig2/JBig2_Segment.cpp
+++ b/core/fxcodec/jbig2/JBig2_Segment.cpp
@@ -8,20 +8,17 @@
#include "core/fxcrt/fx_memory.h"
-CJBig2_Segment::CJBig2_Segment() {
- m_dwNumber = 0;
+CJBig2_Segment::CJBig2_Segment()
+ : m_dwNumber(0),
+ m_nReferred_to_segment_count(0),
+ m_dwPage_association(0),
+ m_dwData_length(0),
+ m_dwHeader_Length(0),
+ m_dwObjNum(0),
+ m_dwDataOffset(0),
+ m_State(JBIG2_SEGMENT_HEADER_UNPARSED),
+ m_nResultType(JBIG2_VOID_POINTER) {
m_cFlags.c = 0;
- m_nReferred_to_segment_count = 0;
- m_pReferred_to_segment_numbers = nullptr;
- m_dwPage_association = 0;
- m_dwData_length = 0;
- m_dwHeader_Length = 0;
- m_dwObjNum = 0;
- m_dwDataOffset = 0;
- m_State = JBIG2_SEGMENT_HEADER_UNPARSED;
- m_nResultType = JBIG2_VOID_POINTER;
}
-CJBig2_Segment::~CJBig2_Segment() {
- FX_Free(m_pReferred_to_segment_numbers);
-}
+CJBig2_Segment::~CJBig2_Segment() {}
diff --git a/core/fxcodec/jbig2/JBig2_Segment.h b/core/fxcodec/jbig2/JBig2_Segment.h
index 26af0f6890..5dc57a37d4 100644
--- a/core/fxcodec/jbig2/JBig2_Segment.h
+++ b/core/fxcodec/jbig2/JBig2_Segment.h
@@ -8,6 +8,7 @@
#define CORE_FXCODEC_JBIG2_JBIG2_SEGMENT_H_
#include <memory>
+#include <vector>
#include "core/fxcodec/jbig2/JBig2_Define.h"
#include "core/fxcodec/jbig2/JBig2_HuffmanTable.h"
@@ -47,7 +48,7 @@ class CJBig2_Segment {
uint8_t c;
} m_cFlags;
int32_t m_nReferred_to_segment_count;
- uint32_t* m_pReferred_to_segment_numbers;
+ std::vector<uint32_t> m_Referred_to_segment_numbers;
uint32_t m_dwPage_association;
uint32_t m_dwData_length;