mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-21 19:00:36 +01:00
MaskEdit: fix potential crash in ApplyMaskToText, that only worked because of implementation details of the internal GetCodePoint function.
This commit is contained in:
parent
4fda5f9771
commit
79c009420a
@ -1812,6 +1812,10 @@ begin
|
|||||||
else
|
else
|
||||||
begin//FMaskSave = False
|
begin//FMaskSave = False
|
||||||
if FTrimType = metTrimRight then
|
if FTrimType = metTrimRight then
|
||||||
|
begin
|
||||||
|
//while GetCodePoint does not crash on an empty string (and it does not return a #32), it sort of worked by accident in that scenario
|
||||||
|
//and it crashed in similar function in MaskUtils because of that, see: https://forum.lazarus.freepascal.org/index.php/topic,60803.0.html
|
||||||
|
if (Value <> '') then
|
||||||
begin
|
begin
|
||||||
//fill text from left to rigth, skipping MaskLiterals
|
//fill text from left to rigth, skipping MaskLiterals
|
||||||
j := 1;
|
j := 1;
|
||||||
@ -1824,10 +1828,13 @@ begin
|
|||||||
if j > Utf8Length(Value) then Break;
|
if j > Utf8Length(Value) then Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
//fill text from right to left, skipping MaskLiterals
|
//fill text from right to left, skipping MaskLiterals
|
||||||
|
if (Value <> '') then
|
||||||
|
begin
|
||||||
j := Utf8Length(Value);
|
j := Utf8Length(Value);
|
||||||
for i := FMaskLength downto 1 do
|
for i := FMaskLength downto 1 do
|
||||||
begin
|
begin
|
||||||
@ -1839,6 +1846,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end;//FMaskSave = False
|
end;//FMaskSave = False
|
||||||
Result := S;
|
Result := S;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user