Skip to content

Commit 39189c3

Browse files
[libc] Fix strftime_test (llvm#165770)
A typo in llvm#165711 caused sanitizer failures (the small buffer was used for the larger test). Renamed the variables to avoid the mistake in future.
1 parent 291b8ce commit 39189c3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

libc/test/src/time/strftime_test.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,20 +2329,21 @@ TEST(LlvmLibcStrftimeTest, TimeFormatFullDateTime) {
23292329

23302330
TEST(LlvmLibcStrftimeTest, BufferTooSmall) {
23312331
struct tm time;
2332-
char buffer[1];
2332+
char tiny_buffer[1];
23332333

23342334
time.tm_year = get_adjusted_year(2025);
23352335
time.tm_mon = 10;
23362336
time.tm_mday = 24;
23372337

23382338
size_t written =
2339-
LIBC_NAMESPACE::strftime(buffer, sizeof(buffer), "%F", &time);
2339+
LIBC_NAMESPACE::strftime(tiny_buffer, sizeof(tiny_buffer), "%F", &time);
23402340
EXPECT_EQ(written, size_t{0});
23412341

2342-
char buffer2[10];
2342+
char small_buffer[10];
23432343

23442344
// The string "2025-11-24" is 10 chars,
23452345
// so strftime needs 10 + 1 bytes to write the string and the null terminator.
2346-
written = LIBC_NAMESPACE::strftime(buffer, sizeof(buffer2), "%F", &time);
2346+
written =
2347+
LIBC_NAMESPACE::strftime(small_buffer, sizeof(small_buffer), "%F", &time);
23472348
EXPECT_EQ(written, size_t{0});
23482349
}

0 commit comments

Comments
 (0)