Integer Overflow in RVStyle.pas
Posted: Tue Jan 31, 2023 2:55 pm
The function PixelsToStandardPixels in RVStyle.pas has to be changed in the following manner (the cast to real was added). Otherwise the usage of the Devexpress Editor Wrapper in 32-Bit will lead to an integer overflow if the text of the editor is empty. Reproduction: Add a Devexpress Tree or Grid Control to a form and use the TcxRichViewEdit as Column-Editor. Compile under 32-Bit and start the application.
{-----------------------------------------------------------------------}
{ Converts pixels from PixelsPerInch to UnitsPixelsPerInch }
function TRVStyle.PixelsToStandardPixels(Value: TRVCoord;
PixelsPerInch: TRVPixelsPerInch): TRVPixelLength;
begin
Result := Round(Real(Value) * UnitsPixelsPerInch / PixelsPerInch);
end;
{-----------------------------------------------------------------------}
{-----------------------------------------------------------------------}
{ Converts pixels from PixelsPerInch to UnitsPixelsPerInch }
function TRVStyle.PixelsToStandardPixels(Value: TRVCoord;
PixelsPerInch: TRVPixelsPerInch): TRVPixelLength;
begin
Result := Round(Real(Value) * UnitsPixelsPerInch / PixelsPerInch);
end;
{-----------------------------------------------------------------------}