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

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

Closed
AppSep opened this issue Aug 25, 2020 · 1 comment
Closed

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

AppSep opened this issue Aug 25, 2020 · 1 comment

Comments

@AppSep
Copy link

AppSep commented Aug 25, 2020

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

Spelt commented Aug 29, 2020

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

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

2 participants