summaryrefslogtreecommitdiff
path: root/fxbarcode/BC_TwoDimWriter.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-04-05 18:42:22 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-06 01:58:05 +0000
commit1b22880748c3f3b3740699ae4c953a33f65ad10f (patch)
tree57d7155639ea2f19dea22cb08ec3ce0b76bcbf9b /fxbarcode/BC_TwoDimWriter.cpp
parent0b18e1599dc9d07355c4ab6a069de33a536f7ba8 (diff)
downloadpdfium-1b22880748c3f3b3740699ae4c953a33f65ad10f.tar.xz
Change some fxbarcode to use return values.
No caller cares about the exception values anyway. Remove the unused ones. Also use more std::unique_ptr to stop potential leaks. Change-Id: Ic5955fb0d879f55e1c6a005c0204df50246dab19 Reviewed-on: https://pdfium-review.googlesource.com/3715 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxbarcode/BC_TwoDimWriter.cpp')
-rw-r--r--fxbarcode/BC_TwoDimWriter.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/fxbarcode/BC_TwoDimWriter.cpp b/fxbarcode/BC_TwoDimWriter.cpp
index 65d28a2090..8043244b2b 100644
--- a/fxbarcode/BC_TwoDimWriter.cpp
+++ b/fxbarcode/BC_TwoDimWriter.cpp
@@ -124,14 +124,8 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code,
multiX = std::min(multiX, multiY);
multiY = multiX;
}
- int32_t leftPadding = (outputWidth - (inputWidth * multiX)) / 2;
- int32_t topPadding = (outputHeight - (inputHeight * multiY)) / 2;
- if (leftPadding < 0) {
- leftPadding = 0;
- }
- if (topPadding < 0) {
- topPadding = 0;
- }
+ int32_t leftPadding = std::max((outputWidth - (inputWidth * multiX)) / 2, 0);
+ int32_t topPadding = std::max((outputHeight - (inputHeight * multiY)) / 2, 0);
m_output = pdfium::MakeUnique<CBC_CommonBitMatrix>();
m_output->Init(outputWidth, outputHeight);
for (int32_t inputY = 0, outputY = topPadding;
@@ -141,9 +135,10 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code,
(inputX < inputWidth) && (outputX < outputWidth - multiX);
inputX++, outputX += multiX) {
if (code[inputX + inputY * inputWidth] == 1) {
- m_output->SetRegion(outputX, outputY, multiX, multiY, e);
- if (e != BCExceptionNO)
+ if (!m_output->SetRegion(outputX, outputY, multiX, multiY)) {
+ e = BCExceptionGeneric;
return;
+ }
}
}
}