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

Side by Side Diff: xfa/fxbarcode/oned/BC_OneDimWriter.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 // Original code is licensed as follows: 6 // Original code is licensed as follows:
7 /* 7 /*
8 * Copyright 2011 ZXing authors 8 * Copyright 2011 ZXing authors
9 * 9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * Licensed under the Apache License, Version 2.0 (the "License");
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 if (device) { 284 if (device) {
285 ShowDeviceChars(device, matrix, str, geWidth, pCharPos, (FX_FLOAT)locX, 285 ShowDeviceChars(device, matrix, str, geWidth, pCharPos, (FX_FLOAT)locX,
286 (FX_FLOAT)locY, barWidth); 286 (FX_FLOAT)locY, barWidth);
287 } else { 287 } else {
288 ShowBitmapChars(pOutBitmap, str, geWidth, pCharPos, (FX_FLOAT)locX, 288 ShowBitmapChars(pOutBitmap, str, geWidth, pCharPos, (FX_FLOAT)locX,
289 (FX_FLOAT)locY, barWidth); 289 (FX_FLOAT)locY, barWidth);
290 } 290 }
291 FX_Free(pCharPos); 291 FX_Free(pCharPos);
292 } 292 }
293
293 void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, 294 void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
294 const CFX_WideStringC& contents, 295 const CFX_WideStringC& contents,
295 int32_t& e) { 296 int32_t& e) {
296 if (m_output == NULL) { 297 if (m_output == NULL) {
297 BC_EXCEPTION_CHECK_ReturnVoid(e); 298 BC_EXCEPTION_CHECK_ReturnVoid(e);
298 } 299 }
299 pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight()); 300 pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight());
300 pOutBitmap->Clear(m_backgroundColor); 301 pOutBitmap->Clear(m_backgroundColor);
301 if (!pOutBitmap) { 302 if (!pOutBitmap) {
302 e = BCExceptionFailToCreateBitmap; 303 e = BCExceptionFailToCreateBitmap;
303 return; 304 return;
304 } 305 }
305 for (int32_t x = 0; x < m_output->GetWidth(); x++) { 306 for (int32_t x = 0; x < m_output->GetWidth(); x++) {
306 for (int32_t y = 0; y < m_output->GetHeight(); y++) { 307 for (int32_t y = 0; y < m_output->GetHeight(); y++) {
307 if (m_output->Get(x, y)) { 308 if (m_output->Get(x, y)) {
308 pOutBitmap->SetPixel(x, y, m_barColor); 309 pOutBitmap->SetPixel(x, y, m_barColor);
309 } 310 }
310 } 311 }
311 } 312 }
312 int32_t i = 0; 313 int32_t i = 0;
313 for (; i < contents.GetLength(); i++) 314 for (; i < contents.GetLength(); i++)
314 if (contents.GetAt(i) != ' ') { 315 if (contents.GetAt(i) != ' ') {
315 break; 316 break;
316 } 317 }
317 if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { 318 if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) {
318 ShowChars(contents, pOutBitmap, NULL, NULL, m_barWidth, m_multiple, e); 319 ShowChars(contents, pOutBitmap, NULL, NULL, m_barWidth, m_multiple, e);
319 BC_EXCEPTION_CHECK_ReturnVoid(e); 320 BC_EXCEPTION_CHECK_ReturnVoid(e);
320 } 321 }
321 CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height); 322 CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height);
322 if (pOutBitmap) { 323 delete pOutBitmap;
323 delete pOutBitmap;
324 }
325 pOutBitmap = pStretchBitmap; 324 pOutBitmap = pStretchBitmap;
326 } 325 }
326
327 void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, 327 void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device,
328 const CFX_Matrix* matrix, 328 const CFX_Matrix* matrix,
329 const CFX_WideStringC& contents, 329 const CFX_WideStringC& contents,
330 int32_t& e) { 330 int32_t& e) {
331 if (m_output == NULL) { 331 if (m_output == NULL) {
332 BC_EXCEPTION_CHECK_ReturnVoid(e); 332 BC_EXCEPTION_CHECK_ReturnVoid(e);
333 } 333 }
334 CFX_GraphStateData stateData; 334 CFX_GraphStateData stateData;
335 CFX_PathData path; 335 CFX_PathData path;
336 path.AppendRect(0, 0, (FX_FLOAT)m_Width, (FX_FLOAT)m_Height); 336 path.AppendRect(0, 0, (FX_FLOAT)m_Width, (FX_FLOAT)m_Height);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 if (outputX + m_multiple > outputWidth && outputWidth - outputX > 0) { 428 if (outputX + m_multiple > outputWidth && outputWidth - outputX > 0) {
429 m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e); 429 m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e);
430 break; 430 break;
431 } 431 }
432 m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e); 432 m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e);
433 BC_EXCEPTION_CHECK_ReturnVoid(e); 433 BC_EXCEPTION_CHECK_ReturnVoid(e);
434 } 434 }
435 outputX += m_multiple; 435 outputX += m_multiple;
436 } 436 }
437 } 437 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp ('k') | xfa/fxbarcode/pdf417/BC_PDF417.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698