You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the end of the procedure, the rounding mode is set back to the original value. However, there may be conditions where the procedure exits prematurely, in particular when a zero-width rect was passed (for whatever reason), but also in case of an exception.
In this case, code execution never reaches the call which resets the rounding mode, and it is left in its rmDown state, which may lead to unexpected behavior in other parts of the application which use Delphi's Round() functions etc.
I think this issue can be solved easily by wrapping the entire code between the two SetRoundMode() calls into a try..finally..end block:
savedRoundMode := SetRoundMode(rmDown);
try// rest of the codefinally
SetRoundMode(savedRoundMode);
end;
Let me know if you need a PR for this.
The text was updated successfully, but these errors were encountered:
Hello,
the
Rasterize
procedure inImg32.Draw
alters the FPU rounding mode by callingSetRoundMode(rmDown)
:Image32/source/Img32.Draw.pas
Line 1007 in b97d05e
At the end of the procedure, the rounding mode is set back to the original value. However, there may be conditions where the procedure exits prematurely, in particular when a zero-width rect was passed (for whatever reason), but also in case of an exception.
In this case, code execution never reaches the call which resets the rounding mode, and it is left in its
rmDown
state, which may lead to unexpected behavior in other parts of the application which use Delphi'sRound()
functions etc.I think this issue can be solved easily by wrapping the entire code between the two
SetRoundMode()
calls into atry..finally..end
block:Let me know if you need a PR for this.
The text was updated successfully, but these errors were encountered: