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

Side by Side Diff: xfa/fxbarcode/pdf417/BC_PDF417.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
« no previous file with comments | « xfa/fxbarcode/oned/BC_OneDimWriter.cpp ('k') | xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2006 Jeremias Maerki in part, and ZXing Authors in part 8 * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part
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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } 394 }
395 CBC_PDF417::CBC_PDF417(FX_BOOL compact) { 395 CBC_PDF417::CBC_PDF417(FX_BOOL compact) {
396 m_compact = compact; 396 m_compact = compact;
397 m_compaction = AUTO; 397 m_compaction = AUTO;
398 m_minCols = 1; 398 m_minCols = 1;
399 m_maxCols = 30; 399 m_maxCols = 30;
400 m_maxRows = 90; 400 m_maxRows = 90;
401 m_minRows = 3; 401 m_minRows = 3;
402 m_barcodeMatrix = NULL; 402 m_barcodeMatrix = NULL;
403 } 403 }
404
404 CBC_PDF417::~CBC_PDF417() { 405 CBC_PDF417::~CBC_PDF417() {
405 if (m_barcodeMatrix) { 406 delete m_barcodeMatrix;
406 delete m_barcodeMatrix;
407 }
408 } 407 }
408
409 CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() { 409 CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() {
410 return m_barcodeMatrix; 410 return m_barcodeMatrix;
411 } 411 }
412 void CBC_PDF417::generateBarcodeLogic(CFX_WideString msg, 412 void CBC_PDF417::generateBarcodeLogic(CFX_WideString msg,
413 int32_t errorCorrectionLevel, 413 int32_t errorCorrectionLevel,
414 int32_t& e) { 414 int32_t& e) {
415 int32_t errorCorrectionCodeWords = 415 int32_t errorCorrectionCodeWords =
416 CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount( 416 CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount(
417 errorCorrectionLevel, e); 417 errorCorrectionLevel, e);
418 BC_EXCEPTION_CHECK_ReturnVoid(e); 418 BC_EXCEPTION_CHECK_ReturnVoid(e);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 if (rows > m_maxRows) { 549 if (rows > m_maxRows) {
550 continue; 550 continue;
551 } 551 }
552 FX_FLOAT newRatio = 552 FX_FLOAT newRatio =
553 ((17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT); 553 ((17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT);
554 if (dimension && 554 if (dimension &&
555 fabsf(newRatio - PREFERRED_RATIO) > fabsf(ratio - PREFERRED_RATIO)) { 555 fabsf(newRatio - PREFERRED_RATIO) > fabsf(ratio - PREFERRED_RATIO)) {
556 continue; 556 continue;
557 } 557 }
558 ratio = newRatio; 558 ratio = newRatio;
559 if (dimension) { 559 delete dimension;
560 delete dimension;
561 }
562 dimension = new CFX_Int32Array; 560 dimension = new CFX_Int32Array;
563 dimension->Add(cols); 561 dimension->Add(cols);
564 dimension->Add(rows); 562 dimension->Add(rows);
565 } 563 }
566 if (dimension == NULL) { 564 if (dimension == NULL) {
567 int32_t rows = calculateNumberOfRows(sourceCodeWords, 565 int32_t rows = calculateNumberOfRows(sourceCodeWords,
568 errorCorrectionCodeWords, m_minCols); 566 errorCorrectionCodeWords, m_minCols);
569 if (rows < m_minRows) { 567 if (rows < m_minRows) {
570 dimension = new CFX_Int32Array; 568 dimension = new CFX_Int32Array;
571 dimension->Add(m_minCols); 569 dimension->Add(m_minCols);
572 dimension->Add(m_minRows); 570 dimension->Add(m_minRows);
573 } else if (rows >= 3 && rows <= 90) { 571 } else if (rows >= 3 && rows <= 90) {
574 dimension = new CFX_Int32Array; 572 dimension = new CFX_Int32Array;
575 dimension->Add(m_minCols); 573 dimension->Add(m_minCols);
576 dimension->Add(rows); 574 dimension->Add(rows);
577 } 575 }
578 } 576 }
579 if (dimension == NULL) { 577 if (dimension == NULL) {
580 e = BCExceptionUnableToFitMessageInColumns; 578 e = BCExceptionUnableToFitMessageInColumns;
581 return NULL; 579 return NULL;
582 } 580 }
583 return dimension; 581 return dimension;
584 } 582 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/oned/BC_OneDimWriter.cpp ('k') | xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698