Wierd bug when using format()

Hi, I have found a pretty wierd bug.

Consider the following code:

imp.configure("Wierd",[],[]); server.log(format("%s","s"));

The result is very surprising, it prints the string
sTRAP in the log.

I have no clue where the “TRAP” comes from. But I can only make it appear when using the format() function, so I guess theres a problem with the implementation.

Another example:
imp.configure("Wierd",[],[]); server.log(format("%s","s")); server.log(format("%s","ss"));
s ssTRAP

This is due to format expecting null terminated strings, but constant strings on the imp aren’t null terminated (they can often include nulls!).

TRAP is actually a section separator in the compiled squirrel code (PART).

This is fixed in later versions, but was quite confusing. Workaround is to add “\x00” at the end of your constant string.

Thank you Hugo!