Skip to content

Commit a5b934d

Browse files
committed
Avoid sanitizer probs inside boost when file doesn't exist
1 parent 0c07352 commit a5b934d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libutil/filesystem.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ Filesystem::read_bytes (string_view path, void *buffer, size_t n, size_t pos)
627627
std::time_t
628628
Filesystem::last_write_time (const std::string& path)
629629
{
630+
if (! exists(path))
631+
return 0;
630632
try {
631633
#ifdef _WIN32
632634
std::wstring wpath = Strutil::utf8_to_utf16 (path);
@@ -645,6 +647,8 @@ Filesystem::last_write_time (const std::string& path)
645647
void
646648
Filesystem::last_write_time (const std::string& path, std::time_t time)
647649
{
650+
if (! exists(path))
651+
return;
648652
try {
649653
#ifdef _WIN32
650654
std::wstring wpath = Strutil::utf8_to_utf16 (path);
@@ -662,6 +666,8 @@ Filesystem::last_write_time (const std::string& path, std::time_t time)
662666
uint64_t
663667
Filesystem::file_size (string_view path)
664668
{
669+
if (! exists(path))
670+
return 0;
665671
try {
666672
#ifdef _WIN32
667673
std::wstring wpath = Strutil::utf8_to_utf16 (path);

0 commit comments

Comments
 (0)