Skip to content

Commit

Permalink
[harbour-barcode] Fixed BitMatrix leak
Browse files Browse the repository at this point in the history
In case if GlobalHistogramBinarizer::getBlackMatrix() throws an exception
like this:

  #0 zxing::Exception::Exception () at Exception.h:34
  #1 ReaderException::ReaderException () at ReaderException.h:30
  #2 NotFoundException::NotFoundException () at NotFoundException.h:28
  #3 zxing::GlobalHistogramBinarizer::estimateBlackPoint() at GlobalHistogramBinarizer.cpp:198
  #4 zxing::GlobalHistogramBinarizer::getBlackMatrix () GlobalHistogramBinarizer.cpp:129
  #5 zxing::BinaryBitmap::getBlackMatrix () BinaryBitmap.cpp:40
  ...
  • Loading branch information
monich committed Feb 3, 2019
1 parent 98deb89 commit e6de8ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/zxing/zxing/common/GlobalHistogramBinarizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
LuminanceSource& source = *getLuminanceSource();
int width = source.getWidth();
int height = source.getHeight();
BitMatrix* matrix = new BitMatrix(width, height);
Ref<BitMatrix> matrix(new BitMatrix(width, height));

// Quickly calculates the histogram by sampling four rows from the image.
// This proved to be more robust on the blackbox tests than sampling a
Expand Down Expand Up @@ -138,7 +138,7 @@ Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
}
}

return Ref<BitMatrix>(matrix);
return matrix;
}

using namespace std;
Expand Down

0 comments on commit e6de8ef

Please sign in to comment.