Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: xfa/fxbarcode/BC_TwoDimWriter.cpp

Issue 1925363002: Do not check pointers before deleting them. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "third_party/base/numerics/safe_math.h" 9 #include "third_party/base/numerics/safe_math.h"
10 #include "xfa/fxbarcode/BC_TwoDimWriter.h" 10 #include "xfa/fxbarcode/BC_TwoDimWriter.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 rect.AppendRect((FX_FLOAT)leftPos + x, (FX_FLOAT)topPos + y, 46 rect.AppendRect((FX_FLOAT)leftPos + x, (FX_FLOAT)topPos + y,
47 (FX_FLOAT)(leftPos + x + 1), (FX_FLOAT)(topPos + y + 1)); 47 (FX_FLOAT)(leftPos + x + 1), (FX_FLOAT)(topPos + y + 1));
48 CFX_GraphStateData stateData; 48 CFX_GraphStateData stateData;
49 if (m_output->Get(x, y)) { 49 if (m_output->Get(x, y)) {
50 device->DrawPath(&rect, &matri, &stateData, m_barColor, 0, 50 device->DrawPath(&rect, &matri, &stateData, m_barColor, 0,
51 FXFILL_WINDING); 51 FXFILL_WINDING);
52 } 52 }
53 } 53 }
54 } 54 }
55 } 55 }
56
56 void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, 57 void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
57 int32_t& e) { 58 int32_t& e) {
58 if (m_bFixedSize) { 59 if (m_bFixedSize) {
59 pOutBitmap = CreateDIBitmap(m_Width, m_Height); 60 pOutBitmap = CreateDIBitmap(m_Width, m_Height);
60 } else { 61 } else {
61 pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight()); 62 pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight());
62 } 63 }
63 if (!pOutBitmap) { 64 if (!pOutBitmap) {
64 e = BCExceptionFailToCreateBitmap; 65 e = BCExceptionFailToCreateBitmap;
65 return; 66 return;
66 } 67 }
67 pOutBitmap->Clear(m_backgroundColor); 68 pOutBitmap->Clear(m_backgroundColor);
68 int32_t leftPos = 0; 69 int32_t leftPos = 0;
69 int32_t topPos = 0; 70 int32_t topPos = 0;
70 if (m_bFixedSize) { 71 if (m_bFixedSize) {
71 leftPos = (m_Width - m_output->GetWidth()) / 2; 72 leftPos = (m_Width - m_output->GetWidth()) / 2;
72 topPos = (m_Height - m_output->GetHeight()) / 2; 73 topPos = (m_Height - m_output->GetHeight()) / 2;
73 } 74 }
74 for (int32_t x = 0; x < m_output->GetWidth(); x++) { 75 for (int32_t x = 0; x < m_output->GetWidth(); x++) {
75 for (int32_t y = 0; y < m_output->GetHeight(); y++) { 76 for (int32_t y = 0; y < m_output->GetHeight(); y++) {
76 if (m_output->Get(x, y)) { 77 if (m_output->Get(x, y)) {
77 pOutBitmap->SetPixel(leftPos + x, topPos + y, m_barColor); 78 pOutBitmap->SetPixel(leftPos + x, topPos + y, m_barColor);
78 } 79 }
79 } 80 }
80 } 81 }
81 if (!m_bFixedSize) { 82 if (!m_bFixedSize) {
82 CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height); 83 CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height);
83 if (pOutBitmap) { 84 delete pOutBitmap;
84 delete pOutBitmap;
85 }
86 pOutBitmap = pStretchBitmap; 85 pOutBitmap = pStretchBitmap;
87 } 86 }
88 } 87 }
88
89 void CBC_TwoDimWriter::RenderResult(uint8_t* code, 89 void CBC_TwoDimWriter::RenderResult(uint8_t* code,
90 int32_t codeWidth, 90 int32_t codeWidth,
91 int32_t codeHeight, 91 int32_t codeHeight,
92 int32_t& e) { 92 int32_t& e) {
93 int32_t inputWidth = codeWidth; 93 int32_t inputWidth = codeWidth;
94 int32_t inputHeight = codeHeight; 94 int32_t inputHeight = codeHeight;
95 int32_t tempWidth = inputWidth + 2; 95 int32_t tempWidth = inputWidth + 2;
96 int32_t tempHeight = inputHeight + 2; 96 int32_t tempHeight = inputHeight + 2;
97 FX_FLOAT moduleHSize = std::min(m_ModuleWidth, m_ModuleHeight); 97 FX_FLOAT moduleHSize = std::min(m_ModuleWidth, m_ModuleHeight);
98 moduleHSize = std::min(moduleHSize, 8.0f); 98 moduleHSize = std::min(moduleHSize, 8.0f);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 for (int32_t inputX = 0, outputX = leftPadding; 139 for (int32_t inputX = 0, outputX = leftPadding;
140 (inputX < inputWidth) && (outputX < outputWidth - multiX); 140 (inputX < inputWidth) && (outputX < outputWidth - multiX);
141 inputX++, outputX += multiX) { 141 inputX++, outputX += multiX) {
142 if (code[inputX + inputY * inputWidth] == 1) { 142 if (code[inputX + inputY * inputWidth] == 1) {
143 m_output->SetRegion(outputX, outputY, multiX, multiY, e); 143 m_output->SetRegion(outputX, outputY, multiX, multiY, e);
144 BC_EXCEPTION_CHECK_ReturnVoid(e); 144 BC_EXCEPTION_CHECK_ReturnVoid(e);
145 } 145 }
146 } 146 }
147 } 147 }
148 } 148 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp ('k') | xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698