Skip to content

Commit 816b5e5

Browse files
[libc] remove use after free in tests.
There were some tests added that attempted to access files after they were closed to test errno behavior, this caused sanitizer issues. Those portions of the tests have been disabled. Differential Revision: https://reviews.llvm.org/D139878
1 parent 6fe6d8d commit 816b5e5

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

libc/test/src/stdio/fileop_test.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,18 @@ TEST(LlvmLibcFILETest, SimpleFileOperations) {
114114

115115
// Check that the other functions correctly set errno.
116116

117-
errno = 0;
118-
ASSERT_NE(__llvm_libc::fseek(file, 0, SEEK_SET), 0);
119-
EXPECT_NE(errno, 0);
120-
121-
errno = 0;
122-
ASSERT_NE(__llvm_libc::fclose(file), 0);
123-
EXPECT_NE(errno, 0);
124-
125-
errno = 0;
126-
ASSERT_EQ(__llvm_libc::fopen("INVALID FILE NAME", "r"),
127-
static_cast<FILE *>(nullptr));
128-
EXPECT_NE(errno, 0);
117+
// errno = 0;
118+
// ASSERT_NE(__llvm_libc::fseek(file, 0, SEEK_SET), 0);
119+
// EXPECT_NE(errno, 0);
120+
121+
// errno = 0;
122+
// ASSERT_NE(__llvm_libc::fclose(file), 0);
123+
// EXPECT_NE(errno, 0);
124+
125+
// errno = 0;
126+
// ASSERT_EQ(__llvm_libc::fopen("INVALID FILE NAME", "r"),
127+
// static_cast<FILE *>(nullptr));
128+
// EXPECT_NE(errno, 0);
129129
}
130130

131131
TEST(LlvmLibcFILETest, FFlush) {

libc/test/src/stdio/ftell_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ class LlvmLibcFTellTest : public __llvm_libc::testing::Test {
5555

5656
ASSERT_EQ(0, __llvm_libc::fclose(file));
5757

58-
errno = 0;
59-
ASSERT_EQ(__llvm_libc::ftell(file), long(-1));
60-
ASSERT_NE(errno, 0);
58+
// errno = 0;
59+
// ASSERT_EQ(__llvm_libc::ftell(file), long(-1));
60+
// ASSERT_NE(errno, 0);
6161
}
6262
};
6363

0 commit comments

Comments
 (0)