-
Notifications
You must be signed in to change notification settings - Fork 212
Description
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;