asan fixes for gcc and gnu runtime

This commit is contained in:
rfm 2024-11-30 19:06:40 +00:00
parent 018111efbb
commit 9cdb4f98ba
5 changed files with 13 additions and 6 deletions

View file

@ -1399,7 +1399,8 @@ unregisterActiveThread(NSThread *thread)
*/
if (i > 15)
{
NSWarnLog(@"Truncating thread name '%s' to 15 characters due to platform limitations", buf);
NSWarnLog(@"Truncating thread name '%s' to 15 characters"
@" due to platform limitations", buf);
i = 15;
}
else
@ -1467,6 +1468,7 @@ nsthreadLauncher(void *thread)
setThreadForCurrentThread(t);
ENTER_POOL
/*
* Let observers know a new thread is starting.
*/
@ -1479,6 +1481,7 @@ nsthreadLauncher(void *thread)
userInfo: nil];
[t _setName: [t name]];
LEAVE_POOL
[t main];

View file

@ -175,8 +175,8 @@ test_encoding(void)
BOOL test_getCString_maxLength_range_remainingRange(void)
{
NS_DURING
unsigned char *referenceBytes;
int referenceBytesLength;
unsigned char referenceBytes[4];
int referenceBytesLength = 4;
NSString *referenceString;
unsigned char buffer[16];
NSRange remainingRange;
@ -186,8 +186,7 @@ BOOL test_getCString_maxLength_range_remainingRange(void)
switch ([NSString defaultCStringEncoding])
{
case NSUTF8StringEncoding:
referenceBytes =(unsigned char []){0x41, 0xc3, 0xa5, 0x42};
referenceBytesLength = 4;
memcpy(referenceBytes, (unsigned char []){0x41, 0xc3, 0xa5, 0x42}, 4);
referenceString = [stringClass stringWithCharacters:
(unichar []){0x41, 0xe5, 0x42}
length: 3];

View file

@ -8,6 +8,7 @@ copyright 2004 Alexander Malmberg <alexander@malmberg.org>
int main(int argc, char **argv)
{
START_SET("zero hash")
NSString *s = @"!)9\" ;";
unsigned int h;
@ -34,7 +35,7 @@ int main(int argc, char **argv)
s = [NSString stringWithString: s];
h = [s hash];
PASS(h != 0, "[NSString hash] does not return 0");
END_SET("zero hash")
return 0;
}

View file

@ -6,6 +6,7 @@
int main(int argc, char **argv)
{
START_SET("noncharacter")
NSString *str;
unichar u;
unichar u2[2];
@ -42,6 +43,7 @@ int main(int argc, char **argv)
PASS([str characterAtIndex: 0] == 0xffff, "ffff is returned properly");
[str release];
END_SET("noncharacter")
return 0;
}

View file

@ -11,6 +11,7 @@ constants.
int main(int argc, char **argv)
{
START_SET("nuls in strings")
NSString *constantString=@"a\0b";
NSString *normalString;
unichar characters[3]={'a',0,'b'};
@ -26,6 +27,7 @@ int main(int argc, char **argv)
r = [normalString rangeOfString: @"\0"];
PASS(1 == r.length && 1 == r.location, "find nul in string");
END_SET("nuls in strings")
return 0;
}