Fix logic error in GSPrivateRangeOfString.

We were checking if the receiver was a specific class, then directly
accessing an ivar of target.  We were then checking if target is a
specific class and, if so, accessing the ivar or target.

This mostly worked because most GNUstep strings have the same
underlying implementation and so the check was passing and by
coincidence giving the correct value.  This breaks when GSTinyStrings
are used more often and was picked up by teaching the compiler to
generate GSTinyStrings for small string literals.
This commit is contained in:
David Chisnall 2018-04-06 10:40:08 +01:00
parent ced3b27144
commit 0ebb50f984

View file

@ -3523,7 +3523,7 @@ GSPrivateRangeOfString(NSString *receiver, NSString *target)
return (GSRSFunc)strRangeUsNs;
}
else if (GSObjCIsKindOf(c, GSCStringClass) == YES
|| (c == GSMutableStringClass && ((GSStr)target)->_flags.wide == 0))
|| (c == GSMutableStringClass && ((GSStr)receiver)->_flags.wide == 0))
{
c = object_getClass(target);
if (GSObjCIsKindOf(c, GSUnicodeStringClass) == YES