Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Violation in Decode #100

Closed
rjmatthews62 opened this issue May 11, 2020 · 5 comments
Closed

Access Violation in Decode #100

rjmatthews62 opened this issue May 11, 2020 · 5 comments

Comments

@rjmatthews62
Copy link

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
Copy link

pult commented May 11, 2020

same for "ZXing.HybridBinarizer.pas"

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

@Spelt
Copy link
Owner

Spelt commented Aug 29, 2020

@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
Copy link
Owner

Spelt commented Aug 29, 2020

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.

@Spelt Spelt closed this as completed Aug 29, 2020
@pult
Copy link

pult commented Aug 29, 2020

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

@Deyken
Copy link

Deyken commented Jul 13, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants