On 11/8/2010 5:08 PM, Levente Uzonyi wrote:
The problem is that the method expects ByteStrings as arguments, but it won't fail if one of them is a WideString. Instead it returns wrong results. Here's an example (in Squeak):
ByteString new findSubstring: 'b' in: 'abc' asWideString startingAt: 1 matchTable: ((0 to: 255) as: ByteArray). "===> 0"
The result is 0, while it should be 2. The problem is worked around in Squeak by making sure that the primitive is not used in this case.
'abc' asWideString findString: 'b' startingAt: 1 caseSensitive: true. "===> 2"
Though a naive user can still use the method as shown here.
Thanks. Looks like a problem in extracting string arguments in translated primitives. With Squeaksource being down again (should we move VMMaker to source.squeak.org?) I've attached a change set with a fix. This adds an additional check for char* arguments in translated prims to ensure that they're actually byte objects.
Cheers, - Andreas