Fixed a serious bug in replace_all() that could make replaces fail or corrupt random data
This commit is contained in:
parent
4bd356079c
commit
3754604686
|
@ -227,7 +227,7 @@ stock replace_all(string[], len, what[], with[])
|
|||
|
||||
while (replace(string[charnum], len, what, with) != 0)
|
||||
{
|
||||
charnum += contain(string[charnum], with) + withlen;
|
||||
charnum += contain(string[charnum], what) + withlen;
|
||||
total++;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ public plugin_init()
|
|||
register_plugin("Format Test", "1.0", "BAILOPAN")
|
||||
|
||||
register_srvcmd("test_format", "Command_TestFormat")
|
||||
register_srvcmd("test_replace", "Command_TestReplace")
|
||||
}
|
||||
|
||||
public Command_TestFormat()
|
||||
|
@ -16,3 +17,14 @@ public Command_TestFormat()
|
|||
server_print("Printing 1 with d: %d", 1)
|
||||
server_print("Printing 1 with u: %u", 1)
|
||||
}
|
||||
|
||||
public Command_TestReplace()
|
||||
{
|
||||
new message[192] = "^"@test^""
|
||||
|
||||
server_print("orig message: %s", message)
|
||||
|
||||
replace_all(message, 191, "^"", "")
|
||||
|
||||
server_print("new message: %s", message)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user