From 5a1bf7d8feb1900fd93ca4f9c613cef4c9cbff93 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Mon, 24 Jul 2017 15:11:30 +0200 Subject: [PATCH] windows: Fix a memory leak in FileSystem::longWinPath Also use c_path_to_UNC directly instead of doing an extra UTF-8->wchar conversion. --- src/libsync/filesystem.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libsync/filesystem.cpp b/src/libsync/filesystem.cpp index c068f4694..18e6f800f 100644 --- a/src/libsync/filesystem.cpp +++ b/src/libsync/filesystem.cpp @@ -54,12 +54,14 @@ Q_LOGGING_CATEGORY(lcFileSystem, "sync.filesystem", QtInfoMsg) QString FileSystem::longWinPath(const QString &inpath) { - QString path(inpath); - #ifdef Q_OS_WIN - path = QString::fromWCharArray(static_cast(c_utf8_path_to_locale(inpath.toUtf8()))); -#endif + const char *unc_str = c_path_to_UNC(inpath.toUtf8()); + QString path = QString::fromUtf8(unc_str); + free((void*)unc_str); return path; +#else + return inpath; +#endif } bool FileSystem::fileEquals(const QString &fn1, const QString &fn2) -- 2.30.2