Page 1 of 1

Integer Overflow in RVStyle.pas

Posted: Tue Jan 31, 2023 2:55 pm
by vogel_m13
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;
{-----------------------------------------------------------------------}

Re: Integer Overflow in RVStyle.pas

Posted: Sat Feb 04, 2023 9:36 am
by Sergey Tkachenko
Thank you!
I'll reorder operands to perform division before multiplication, like in most of other similar expressions in RVStyle unit.