mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 13:27:36 +00:00
LibC: Make asctime_r() in time.h POSIX compliant
Previously, when the asctime_r() buffer overflowed, we would fail an assertion. This patch modifies asctime_r() to instead set errno and return null.
This commit is contained in:
parent
0ecf17cf91
commit
47f4bfea35
1 changed files with 5 additions and 2 deletions
|
@ -208,8 +208,11 @@ char* asctime_r(const struct tm* tm, char* buffer)
|
||||||
constexpr size_t assumed_len = 26;
|
constexpr size_t assumed_len = 26;
|
||||||
size_t filled_size = strftime(buffer, assumed_len, "%a %b %e %T %Y\n", tm);
|
size_t filled_size = strftime(buffer, assumed_len, "%a %b %e %T %Y\n", tm);
|
||||||
|
|
||||||
// Verify that the buffer was large enough.
|
// If the buffer was not large enough, set EOVERFLOW and return null.
|
||||||
VERIFY(filled_size != 0);
|
if (filled_size == 0) {
|
||||||
|
errno = EOVERFLOW;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue