summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxbarcode')
-rw-r--r--xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp59
-rw-r--r--xfa/fxbarcode/BC_TwoDimWriter.cpp6
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp14
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.cpp6
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417.cpp10
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp18
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp8
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp148
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp12
9 files changed, 90 insertions, 191 deletions
diff --git a/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp b/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp
index c39d3c6eb0..982cc9c4ad 100644
--- a/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp
+++ b/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp
@@ -20,6 +20,8 @@
* limitations under the License.
*/
+#include <memory>
+
#include "core/fxcodec/codec/include/ccodec_progressivedecoder.h"
#include "core/fxcodec/include/fx_codec.h"
#include "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h"
@@ -32,60 +34,35 @@ class CBC_Pause : public IFX_Pause {
};
static CFX_DIBitmap* CreateDIBSource(IFX_FileRead* fileread) {
- CFX_DIBitmap* bitmap = nullptr;
- CCodec_ModuleMgr* pCodecMgr = nullptr;
- CCodec_ProgressiveDecoder* pImageCodec = nullptr;
- pCodecMgr = new CCodec_ModuleMgr();
- pImageCodec = pCodecMgr->CreateProgressiveDecoder();
+ std::unique_ptr<CCodec_ModuleMgr> pCodecMgr(new CCodec_ModuleMgr());
+ std::unique_ptr<CCodec_ProgressiveDecoder> pImageCodec(
+ pCodecMgr->CreateProgressiveDecoder());
FXCODEC_STATUS status = FXCODEC_STATUS_DECODE_FINISH;
status = pImageCodec->LoadImageInfo(fileread, FXCODEC_IMAGE_UNKNOWN, nullptr);
if (status != FXCODEC_STATUS_FRAME_READY)
return nullptr;
- bitmap = new CFX_DIBitmap;
+ std::unique_ptr<CFX_DIBitmap> bitmap(new CFX_DIBitmap);
bitmap->Create(pImageCodec->GetWidth(), pImageCodec->GetHeight(), FXDIB_Argb);
bitmap->Clear(FXARGB_MAKE(0xFF, 0xFF, 0xFF, 0xFF));
CBC_Pause pause;
int32_t frames;
status = pImageCodec->GetFrames(frames, &pause);
- while (status == FXCODEC_STATUS_FRAME_TOBECONTINUE) {
+ while (status == FXCODEC_STATUS_FRAME_TOBECONTINUE)
status = pImageCodec->GetFrames(frames, &pause);
- }
- if (status != FXCODEC_STATUS_DECODE_READY) {
- goto except;
- }
- status = pImageCodec->StartDecode(bitmap, 0, 0, bitmap->GetWidth(),
+
+ if (status != FXCODEC_STATUS_DECODE_READY)
+ return nullptr;
+
+ status = pImageCodec->StartDecode(bitmap.get(), 0, 0, bitmap->GetWidth(),
bitmap->GetHeight(), 0, FALSE);
- if (status == FXCODEC_STATUS_ERR_PARAMS) {
- goto except;
- }
- if (status != FXCODEC_STATUS_DECODE_TOBECONTINUE) {
- goto except;
- }
- while (status == FXCODEC_STATUS_DECODE_TOBECONTINUE) {
+ if (status != FXCODEC_STATUS_DECODE_TOBECONTINUE)
+ return nullptr;
+
+ while (status == FXCODEC_STATUS_DECODE_TOBECONTINUE)
status = pImageCodec->ContinueDecode(&pause);
- }
- if (status != FXCODEC_STATUS_DECODE_FINISH) {
- goto except;
- }
- if (pImageCodec) {
- delete pImageCodec;
- pImageCodec = nullptr;
- }
- delete pCodecMgr;
- pCodecMgr = nullptr;
- return bitmap;
-except:
- if (pImageCodec) {
- delete pImageCodec;
- pImageCodec = nullptr;
- }
- delete pCodecMgr;
- pCodecMgr = nullptr;
- if (bitmap) {
- delete bitmap;
- }
- return nullptr;
+
+ return status == FXCODEC_STATUS_DECODE_FINISH ? bitmap.release() : nullptr;
}
CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource(
diff --git a/xfa/fxbarcode/BC_TwoDimWriter.cpp b/xfa/fxbarcode/BC_TwoDimWriter.cpp
index f0065a02b9..a844bf1c42 100644
--- a/xfa/fxbarcode/BC_TwoDimWriter.cpp
+++ b/xfa/fxbarcode/BC_TwoDimWriter.cpp
@@ -53,6 +53,7 @@ void CBC_TwoDimWriter::RenderDeviceResult(CFX_RenderDevice* device,
}
}
}
+
void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
int32_t& e) {
if (m_bFixedSize) {
@@ -80,12 +81,11 @@ void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
}
if (!m_bFixedSize) {
CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height);
- if (pOutBitmap) {
- delete pOutBitmap;
- }
+ delete pOutBitmap;
pOutBitmap = pStretchBitmap;
}
}
+
void CBC_TwoDimWriter::RenderResult(uint8_t* code,
int32_t codeWidth,
int32_t codeHeight,
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
index 5e9fd33ac4..33771418d4 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
@@ -31,16 +31,14 @@ void CBC_ReedSolomonGF256::Initialize() {
DataMatrixField = new CBC_ReedSolomonGF256(0x012D);
DataMatrixField->Init();
}
+
void CBC_ReedSolomonGF256::Finalize() {
- if (QRCodeFild) {
- delete QRCodeFild;
- }
- QRCodeFild = NULL;
- if (DataMatrixField) {
- delete DataMatrixField;
- }
- DataMatrixField = NULL;
+ delete QRCodeFild;
+ QRCodeFild = nullptr;
+ delete DataMatrixField;
+ DataMatrixField = nullptr;
}
+
CBC_ReedSolomonGF256::CBC_ReedSolomonGF256(int32_t primitive) {
int32_t x = 1;
for (int32_t j = 0; j < 256; j++) {
diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
index b95c2be283..ae1b237957 100644
--- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -290,6 +290,7 @@ void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents,
}
FX_Free(pCharPos);
}
+
void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
const CFX_WideStringC& contents,
int32_t& e) {
@@ -319,11 +320,10 @@ void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
BC_EXCEPTION_CHECK_ReturnVoid(e);
}
CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height);
- if (pOutBitmap) {
- delete pOutBitmap;
- }
+ delete pOutBitmap;
pOutBitmap = pStretchBitmap;
}
+
void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device,
const CFX_Matrix* matrix,
const CFX_WideStringC& contents,
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417.cpp b/xfa/fxbarcode/pdf417/BC_PDF417.cpp
index 15b448b37b..908901c04e 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417.cpp
@@ -401,11 +401,11 @@ CBC_PDF417::CBC_PDF417(FX_BOOL compact) {
m_minRows = 3;
m_barcodeMatrix = NULL;
}
+
CBC_PDF417::~CBC_PDF417() {
- if (m_barcodeMatrix) {
- delete m_barcodeMatrix;
- }
+ delete m_barcodeMatrix;
}
+
CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() {
return m_barcodeMatrix;
}
@@ -556,9 +556,7 @@ CFX_Int32Array* CBC_PDF417::determineDimensions(
continue;
}
ratio = newRatio;
- if (dimension) {
- delete dimension;
- }
+ delete dimension;
dimension = new CFX_Int32Array;
dimension->Add(cols);
dimension->Add(rows);
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp b/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp
index c8328ab1c6..d2ad98e408 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp
@@ -42,20 +42,14 @@ CBC_BoundingBox::CBC_BoundingBox(CBC_BoundingBox* boundingBox) {
init(boundingBox->m_image, boundingBox->m_topLeft, boundingBox->m_bottomLeft,
boundingBox->m_topRight, boundingBox->m_bottomRight);
}
+
CBC_BoundingBox::~CBC_BoundingBox() {
- if (m_topLeft) {
- delete m_topLeft;
- }
- if (m_bottomLeft) {
- delete m_bottomLeft;
- }
- if (m_topRight) {
- delete m_topRight;
- }
- if (m_bottomRight) {
- delete m_bottomRight;
- }
+ delete m_topLeft;
+ delete m_bottomLeft;
+ delete m_topRight;
+ delete m_bottomRight;
}
+
CBC_BoundingBox* CBC_BoundingBox::merge(CBC_BoundingBox* leftBox,
CBC_BoundingBox* rightBox,
int32_t& e) {
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp
index cfd52e56dc..345efd5648 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp
@@ -114,9 +114,7 @@ CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple,
CFX_PtrArray* vertices = findVertices(bitMatrix, row, column);
if (vertices->GetAt(0) == NULL && vertices->GetAt(3) == NULL) {
if (!foundBarcodeInRow) {
- if (vertices) {
- delete (vertices);
- }
+ delete vertices;
break;
}
foundBarcodeInRow = FALSE;
@@ -132,9 +130,7 @@ CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple,
}
}
row += ROW_STEP;
- if (vertices) {
- delete (vertices);
- }
+ delete vertices;
continue;
}
foundBarcodeInRow = TRUE;
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp
index 830b65e199..2c96f7005f 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp
@@ -153,32 +153,20 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm(
n = j;
if (rLast->isZero()) {
e = BCExceptionChecksumException;
- if (qtemp) {
- delete qtemp;
- }
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete qtemp;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
r = rLastLast;
CBC_PDF417ECModulusPoly* q = m_field->getZero();
int32_t denominatorLeadingTerm = rLast->getCoefficient(rLast->getDegree());
int32_t dltInverse = m_field->inverse(denominatorLeadingTerm, e);
if (e != BCExceptionNO) {
- if (qtemp) {
- delete qtemp;
- }
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete qtemp;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
while (r->getDegree() >= rLast->getDegree() && !r->isZero()) {
int32_t degreeDiff = r->getDegree() - rLast->getDegree();
@@ -187,81 +175,51 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm(
CBC_PDF417ECModulusPoly* buildmonomial =
m_field->buildMonomial(degreeDiff, scale, e);
if (e != BCExceptionNO) {
- if (qtemp) {
- delete qtemp;
- }
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete qtemp;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
q = q->add(buildmonomial, e);
delete buildmonomial;
- if (qtemp) {
- delete qtemp;
- }
+ delete qtemp;
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
qtemp = q;
CBC_PDF417ECModulusPoly* multiply =
rLast->multiplyByMonomial(degreeDiff, scale, e);
if (e != BCExceptionNO) {
- if (qtemp) {
- delete qtemp;
- }
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete qtemp;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
CBC_PDF417ECModulusPoly* temp = r;
r = temp->subtract(multiply, e);
delete multiply;
if (m > 1 && i > m) {
delete temp;
- temp = NULL;
+ temp = nullptr;
}
if (e != BCExceptionNO) {
- if (qtemp) {
- delete qtemp;
- }
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete qtemp;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
rtemp = r;
i = m + 1;
}
ttemp = q->multiply(tLast, e);
- if (qtemp) {
- delete qtemp;
- qtemp = NULL;
- }
+ delete qtemp;
+ qtemp = nullptr;
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
t = ttemp->subtract(tLastLast, e);
if (n > 1 && j > n) {
@@ -269,19 +227,15 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm(
}
delete ttemp;
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- return NULL;
+ delete rtemp;
+ return nullptr;
}
ttemp = t;
t = ttemp->negative(e);
delete ttemp;
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- return NULL;
+ delete rtemp;
+ return nullptr;
}
ttemp = t;
j++;
@@ -289,38 +243,24 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm(
int32_t sigmaTildeAtZero = t->getCoefficient(0);
if (sigmaTildeAtZero == 0) {
e = BCExceptionChecksumException;
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
int32_t inverse = m_field->inverse(sigmaTildeAtZero, e);
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
- }
- CBC_PDF417ECModulusPoly* sigma = t->multiply(inverse, e);
- if (ttemp) {
+ delete rtemp;
delete ttemp;
+ return nullptr;
}
+ CBC_PDF417ECModulusPoly* sigma = t->multiply(inverse, e);
+ delete ttemp;
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- return NULL;
- }
- CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e);
- if (rtemp) {
delete rtemp;
+ return nullptr;
}
+ CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e);
+ delete rtemp;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
CFX_PtrArray* modulusPoly = new CFX_PtrArray;
modulusPoly->Add(sigma);
diff --git a/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp b/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp
index 716b6c17de..fc87785d5c 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp
@@ -93,14 +93,10 @@ CFX_ByteString CBC_QRCodeReader::Decode(CBC_BinaryBitmap* image, int32_t& e) {
return bs;
}
void CBC_QRCodeReader::ReleaseAll() {
- if (CBC_ReedSolomonGF256::QRCodeFild) {
- delete CBC_ReedSolomonGF256::QRCodeFild;
- CBC_ReedSolomonGF256::QRCodeFild = NULL;
- }
- if (CBC_ReedSolomonGF256::DataMatrixField) {
- delete CBC_ReedSolomonGF256::DataMatrixField;
- CBC_ReedSolomonGF256::DataMatrixField = NULL;
- }
+ delete CBC_ReedSolomonGF256::QRCodeFild;
+ CBC_ReedSolomonGF256::QRCodeFild = nullptr;
+ delete CBC_ReedSolomonGF256::DataMatrixField;
+ CBC_ReedSolomonGF256::DataMatrixField = nullptr;
CBC_QRCoderMode::Destroy();
CBC_QRCoderErrorCorrectionLevel::Destroy();
CBC_QRDataMask::Destroy();