Fix memory leak in BLI_file_older for WIN32

Error from [0] which added UTF16 path support,
resolve using `BLI_stat` to avoid inline allocation.

[0]: f11a6d3a84
This commit is contained in:
Campbell Barton
2023-05-16 11:24:14 +10:00
parent 4b4babae8b
commit 5d695b4f06

View File

@@ -602,30 +602,12 @@ void BLI_file_free_lines(LinkNode *lines)
bool BLI_file_older(const char *file1, const char *file2)
{
#ifdef WIN32
struct _stat st1, st2;
UTF16_ENCODE(file1);
UTF16_ENCODE(file2);
if (_wstat(file1_16, &st1)) {
BLI_stat_t st1, st2;
if (BLI_stat(file1, &st1)) {
return false;
}
if (_wstat(file2_16, &st2)) {
if (BLI_stat(file2, &st2)) {
return false;
}
UTF16_UN_ENCODE(file2);
UTF16_UN_ENCODE(file1);
#else
struct stat st1, st2;
if (stat(file1, &st1)) {
return false;
}
if (stat(file2, &st2)) {
return false;
}
#endif
return (st1.st_mtime < st2.st_mtime);
}