Skip to content

Commit b0342bd

Browse files
committed
libstd: Fixed crash when passing invalid values to std::time functions
1 parent a59aa47 commit b0342bd

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

lib/source/pl/lib/std/time.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ namespace pl::lib::libstd::time {
5858

5959
try {
6060
auto localTime = std::localtime(&time);
61+
if (localTime == nullptr) return u128(0);
6162

6263
return { packTMValue(*localTime) };
6364
} catch (const fmt::format_error&) {
@@ -71,6 +72,7 @@ namespace pl::lib::libstd::time {
7172

7273
try {
7374
auto gmTime = std::gmtime(&time);
75+
if (gmTime == nullptr) return u128(0);
7476

7577
return { packTMValue(*gmTime) };
7678
} catch (const fmt::format_error&) {

0 commit comments

Comments
 (0)