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

ZXing.Common.BitMatrix Range Check Error Delphi 10.x(1,2,3,4) #104

Closed AppSep closed 4 years ago

AppSep commented 4 years ago

Hi, there is a range check error in the ZXing.Common.BitMatrix.pas. the integer var must be Int64, because the function TMathUtils.Asr return int64.

//original function TBitMatrix.getBit(x, y: Integer): Boolean; var offset, v, bits, shift: Integer; uBits: Cardinal; begin offset := y * FrowSize + TMathUtils.Asr(x, 5); try bits := Fbits[offset]; uBits := Cardinal(bits); shift := (x and $1F); v := TMathUtils.Asr(uBits, shift); Result := (v and 1) <> 0; except Result := false; end; end;

//fixed function TBitMatrix.getBit(x, y: Integer): Boolean; var offset, v, bits, shift: Int64; uBits: Cardinal; begin offset := y * FrowSize + TMathUtils.Asr(x, 5); try bits := Fbits[offset]; uBits := Cardinal(bits); shift := (x and $1F); v := TMathUtils.Asr(uBits, shift); Result := (v and 1) <> 0; except Result := false; end; end;

Spelt commented 4 years ago

Thanks! It will be fixed in the next version. Will be released today.