Fix game freezing if Format arg contains '%1', '%2', etc. (
bug #851)
--- a/hedgewars/uLocale.pas Fri Jun 16 21:06:46 2023 +0200
+++ b/hedgewars/uLocale.pas Mon Jun 19 14:09:37 2023 +0200
@@ -164,6 +164,10 @@
8: curArg:= arg9;
end;
+ // Replace % sign in argument with ASCII ESC
+ // to prevent infinite loop below.
+ curArg:= StringReplace(curArg, '%', Char($1B), [rfReplaceAll]);
+
repeat
p:= Pos('%'+IntToStr(i+1), tempstr);
if (p <> 0) then
@@ -173,6 +177,8 @@
end;
until (p = 0);
end;
+
+tempstr:= StringReplace(tempstr, Char($1B), '%', [rfReplaceAll]);
Format:= tempstr;
end;
@@ -196,6 +202,10 @@
8: curArg:= arg9;
end;
+ // Replace % sign in argument with ASCII ESC
+ // to prevent infinite loop below.
+ curArg:= StringReplace(curArg, '%', Char($1B), [rfReplaceAll]);
+
repeat
p:= Pos('%'+IntToStr(i+1), tempstr);
if (p <> 0) then
@@ -205,6 +215,8 @@
end;
until (p = 0);
end;
+
+tempstr:= StringReplace(tempstr, Char($1B), '%', [rfReplaceAll]);
FormatA:= tempstr;
end;