Fixed a serious bug in replace_all() that could make replaces fail or corrupt random data

This commit is contained in:
David Anderson 2006-09-10 07:23:08 +00:00
parent 4bd356079c
commit 3754604686
2 changed files with 13 additions and 1 deletions

View File

@ -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++;
}

View File

@ -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)
}