Spelt / ZXing.Delphi

ZXing Barcode Scanning object Pascal Library for Delphi VCL and Delphi Firemonkey
Apache License 2.0
471 stars 206 forks source link

Access Violation in Decode #100

Closed rjmatthews62 closed 4 years ago

rjmatthews62 commented 4 years ago

I'm getting an Access violation in: Lib\Classes\2D Barcodes\Decoder\ZXing.Datamatrix.Internal.Decoder.pas

function TDataMatrixDecoder.decode(bits: TBitMatrix): TDecoderResult;

It's happening when the finally section frees DataBlock

And this is happening because there are some situations where Datablock is undefined at that point. The fix is the initialize DataBlock to nil at the top of the function.

Issue is occurring in Delphi 10.2, Win 32, VCL

pult commented 4 years ago

same for "ZXing.HybridBinarizer.pas"

procedure THybridBinarizer.BinarizeEntireImage;
...
newMatrix := nil; //+
try
...
      self.matrix := newMatrix;
      newMatrix := nil; //+
  finally
    //newMatrix := nil; //-
    newMatrix.Free;  //+
...
Spelt commented 4 years ago

@m

I'm getting an Access violation in: Lib\Classes\2D Barcodes\Decoder\ZXing.Datamatrix.Internal.Decoder.pas

function TDataMatrixDecoder.decode(bits: TBitMatrix): TDecoderResult;

It's happening when the finally section frees DataBlock

And this is happening because there are some situations where Datablock is undefined at that point. The fix is the initialize DataBlock to nil at the top of the function.

Issue is occurring in Delphi 10.2, Win 32, VCL

Thanks! The fix will be in the next release today.

Spelt commented 4 years ago

procedure THybridBinarizer.BinarizeEntireImage; ... newMatrix := nil; //+ try ... self.matrix := newMatrix; newMatrix := nil; //+ finally //newMatrix := nil; //- newMatrix.Free; //+ ...

Hi Pult,

I do not agree with you here:

self.matrix points now to the newMatrix. Freeing newMatrix will free self.matrix. The initialization of the the varaible newMatrix is good and will be in the next release (today).

If I have it wrong please open a seperate issue and we can discuss it.

pult commented 4 years ago

see: newMatrix := nil; newMatrix is freed only in case of an exception

Deyken commented 3 years ago

Hi Spelt! For some reason, when generating a new QR Code, it consistently omits all zeros (0). Is there a setting for this, or could it possibly be a bug? When I use leading zeros for a string to encode, all the zeros show up. But whenever a zero finds itself in the middle pf a string, ZXing omits it. All zeros are simply removed from the result string. Code output is set to Auto and the quiet zone is set to 4.