Skip to content

Commit 636787e

Browse files
authored
Fix asan and lsan tests after #24831. NFC (#24856)
Fixes: #24852
1 parent df9dfe0 commit 636787e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

test/fs/test_getcwd_with_non_ascii_name.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
#include <sys/stat.h>
1212
#include <unistd.h>
1313

14+
char* lastLongString;
15+
1416
char* makeLongStr(const char* str, int strCount) {
15-
char* result = malloc((strCount * strlen(str)) + 1);
17+
char* result = lastLongString = realloc(lastLongString, (strCount * strlen(str)) + 1);;
1618
result[0] = '\0';
1719

1820
for (int i = 0; i < strCount; ++i) {
@@ -72,4 +74,6 @@ int main() {
7274

7375
// The negative test passes a half-sized buffer to getcwd and makes sure that it fails.
7476
doNegativeTest(makeLongStr(u8"abcde", 10));
77+
78+
free(lastLongString);
7579
}

test/fs/test_getdents64_special_cases.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ int main() {
5656
#ifndef WASMFS // The JS FS truncates filenames automatically, which is incorrect. Wasmfs and Linux do not.
5757
// File name exceeds the limit of 255 chars and is truncated.
5858
char longName[300];
59-
memset(longName, 1, sizeof(longName));
59+
memset(longName, '1', sizeof(longName));
60+
longName[sizeof(longName) - 1] = '\0';
6061
doTest("test_dir2", longName);
6162
#endif
6263
}

0 commit comments

Comments
 (0)