Skip to content

Commit

Permalink
asan fixes for gcc and gnu runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Nov 30, 2024
1 parent 018111e commit 9cdb4f9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Source/NSThread.m
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,8 @@ - (void) _setName: (NSString *)aName
*/
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
Expand Down Expand Up @@ -1467,6 +1468,7 @@ - (NSUInteger) stackSize

setThreadForCurrentThread(t);

ENTER_POOL
/*
* Let observers know a new thread is starting.
*/
Expand All @@ -1479,6 +1481,7 @@ - (NSUInteger) stackSize
userInfo: nil];

[t _setName: [t name]];
LEAVE_POOL

[t main];

Expand Down
7 changes: 3 additions & 4 deletions Tests/base/NSString/NSString_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand Down
3 changes: 2 additions & 1 deletion Tests/base/NSString/NSString_zero_hash.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

int main(int argc, char **argv)
{
START_SET("zero hash")
NSString *s = @"!)9\" ;";
unsigned int h;

Expand All @@ -34,7 +35,7 @@ Generate a (hopefully ASCII printable) string with a given hash.
s = [NSString stringWithString: s];
h = [s hash];
PASS(h != 0, "[NSString hash] does not return 0");

END_SET("zero hash")
return 0;
}

2 changes: 2 additions & 0 deletions Tests/base/NSString/noncharacter.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

int main(int argc, char **argv)
{
START_SET("noncharacter")
NSString *str;
unichar u;
unichar u2[2];
Expand Down Expand Up @@ -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;
}

2 changes: 2 additions & 0 deletions Tests/base/NSString/nuls_in_strings.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

int main(int argc, char **argv)
{
START_SET("nuls in strings")
NSString *constantString=@"a\0b";
NSString *normalString;
unichar characters[3]={'a',0,'b'};
Expand All @@ -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;
}

0 comments on commit 9cdb4f9

Please sign in to comment.