summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/pdf417
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-12-11 16:26:00 -0800
committerTom Sepez <tsepez@chromium.org>2015-12-11 16:26:00 -0800
commitf75bdb181576e4a4cf8291706a0db86c687e5fc3 (patch)
tree4440158d95c723b1ef02753b4dfa9d1a598e1a87 /xfa/src/fxbarcode/pdf417
parent74aa4e19a332436ff3bcf539c905e992b1d3ac4e (diff)
downloadpdfium-f75bdb181576e4a4cf8291706a0db86c687e5fc3.tar.xz
XFA: avoid multiplications in FX_Allocs
In some cases, we can use the safe FX_Alloc2D, in others there's an extra multiplication by the size of the type. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1519233002 .
Diffstat (limited to 'xfa/src/fxbarcode/pdf417')
-rw-r--r--xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp4
-rw-r--r--xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp2
-rw-r--r--xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp
index af63d19bfe..ba822ce1d2 100644
--- a/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp
+++ b/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp
@@ -360,7 +360,7 @@ int32_t CBC_DecodedBitStreamPaser::byteCompaction(int32_t mode,
if (mode == BYTE_COMPACTION_MODE_LATCH) {
int32_t count = 0;
int64_t value = 0;
- FX_WORD* decodedData = FX_Alloc(FX_WORD, 6 * sizeof(FX_WORD));
+ FX_WORD* decodedData = FX_Alloc(FX_WORD, 6);
CFX_Int32Array byteCompactedCodewords;
byteCompactedCodewords.SetSize(6);
FX_BOOL end = FALSE;
@@ -421,7 +421,7 @@ int32_t CBC_DecodedBitStreamPaser::byteCompaction(int32_t mode,
}
}
if ((count % 5 == 0) && (count > 0)) {
- FX_WORD* decodedData = FX_Alloc(FX_WORD, 6 * sizeof(FX_WORD));
+ FX_WORD* decodedData = FX_Alloc(FX_WORD, 6);
int32_t j = 0;
for (; j < 6; ++j) {
decodedData[5 - j] = (FX_WORD)(value & 0xFF);
diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
index 0fd275c4e6..b0518c6f2c 100644
--- a/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
+++ b/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
@@ -135,7 +135,7 @@ CFX_WideString CBC_PDF417ErrorCorrection::generateErrorCorrection(
int32_t& e) {
int32_t k = getErrorCorrectionCodewordCount(errorCorrectionLevel, e);
BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR)' ');
- FX_WCHAR* ech = FX_Alloc(FX_WCHAR, k * sizeof(FX_WCHAR));
+ FX_WCHAR* ech = FX_Alloc(FX_WCHAR, k);
FXSYS_memset(ech, 0, k * sizeof(FX_WCHAR));
int32_t sld = dataCodewords.GetLength();
for (int32_t i = 0; i < sld; i++) {
diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp
index 457b30b750..d922889b3d 100644
--- a/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp
+++ b/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp
@@ -97,7 +97,7 @@ uint8_t* CBC_PDF417Writer::Encode(const CFX_WideString& contents,
outWidth = temp;
}
}
- uint8_t* result = (uint8_t*)FX_Alloc(uint8_t, outHeight * outWidth);
+ uint8_t* result = FX_Alloc2D(uint8_t, outHeight, outWidth);
FXSYS_memcpy(result, originalScale.GetData(), outHeight * outWidth);
return result;
}