Skip to content

Commit 6355f38

Browse files
author
Zishan Mirza
committed
fix: check if timer variable is nullptr
1 parent 0cef892 commit 6355f38

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

libc/src/time/linux/localtime_r.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ namespace LIBC_NAMESPACE_DECL {
1313

1414
LLVM_LIBC_FUNCTION(struct tm *, localtime_r,
1515
(const time_t *timer, struct tm *buf)) {
16+
if (timer == nullptr) {
17+
return nullptr;
18+
}
19+
1620
return time_utils::localtime_internal(timer, buf);
1721
}
1822

libc/src/time/linux/localtime_s.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ namespace LIBC_NAMESPACE_DECL {
1313

1414
// windows only, implemented in gnu/linux for compatibility reasons
1515
LLVM_LIBC_FUNCTION(int, localtime_s, (const time_t *timer, struct tm *input)) {
16+
if (timer == nullptr) {
17+
return nullptr;
18+
}
19+
1620
return time_utils::localtime_s_internal(timer, input);
1721
}
1822

0 commit comments

Comments
 (0)