Skip to content

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

@AppSep

Description

@AppSep

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions