Integer Overflow in RVStyle.pas

General TRichView support forum. Please post your questions here
Post Reply
vogel_m13
Posts: 1
Joined: Tue Jan 31, 2023 1:52 pm

Integer Overflow in RVStyle.pas

Post 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;
{-----------------------------------------------------------------------}
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Integer Overflow in RVStyle.pas

Post by Sergey Tkachenko »

Thank you!
I'll reorder operands to perform division before multiplication, like in most of other similar expressions in RVStyle unit.
Post Reply