windows: Fix a memory leak in FileSystem::longWinPath
authorJocelyn Turcotte <jturcotte@woboq.com>
Mon, 24 Jul 2017 13:11:30 +0000 (15:11 +0200)
committerJocelyn Turcotte <jturcotte@woboq.com>
Mon, 24 Jul 2017 15:54:29 +0000 (17:54 +0200)
Also use c_path_to_UNC directly instead of doing an extra
UTF-8->wchar conversion.

src/libsync/filesystem.cpp

index c068f46943cdcbe25e8055e935ecf6a4fc6bda82..18e6f800ffebee63feb163aeac685e31ea00f566 100644 (file)
@@ -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<wchar_t *>(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)