AV with a big font
Posted: Thu Mar 26, 2015 1:44 pm
If somebody types a letter, then sets a font size of the letter to 99 or more, then chooses the font named "Flut Saus" (http://www.dafont.com/flutsaus.font), there will be an AV:
Project .... raised exception class EAccessViolation with message 'Access violation at address 0113EBB4 in module '...'. Read of address 4A9B1ED0'.
It is because of uninitialized variable Result in the function MaxFitSafe. The value of the variable is bigger than the length of the word.
As I can see, Result should be initialized here:
But it does not happen, because of function Windows.GetTextExtentExPointW. It returns False and does not calculate any other values.
The font Flut Saus is not only one that makes this error.
TRVWinGraphicInterface.GetTextExtentExPoint_W is a procedure so we cant check its result.
What can we do to prevent this error?
Project .... raised exception class EAccessViolation with message 'Access violation at address 0113EBB4 in module '...'. Read of address 4A9B1ED0'.
It is because of uninitialized variable Result in the function MaxFitSafe. The value of the variable is bigger than the length of the word.
As I can see, Result should be initialized here:
Code: Select all
if (rvpaoNoWrap in pi.Options) or not Params.AllowWordWrap then
Result := MaxLen
else begin
RVU_GetTextExtentExPointPC(Params.FormatCanvas, SourceStrPtr, MaxLen,
RVConvertToFormatCanvas(SpaceTillTheEndOfLine, Params.UseFormatCanvas),
Result, nil, li.ItemOptions, sz, RVStyle.GraphicInterface);
The font Flut Saus is not only one that makes this error.
TRVWinGraphicInterface.GetTextExtentExPoint_W is a procedure so we cant check its result.
What can we do to prevent this error?