Fix leak in FileUtil::IsChildFile
authorKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 12 May 2020 12:32:34 +0000 (14:32 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 12 May 2020 12:32:34 +0000 (14:32 +0200)
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
shell_integration/windows/OCUtil/FileUtil.cpp

index a0d381c9236589c07220424968935dd35428040e..9bb27af9208af5d0dfecd6bf685384ea5c3f897f 100644 (file)
@@ -39,9 +39,9 @@ bool FileUtil::IsChildFile(const wchar_t* rootFolder, vector<wstring>* files)
 
 bool FileUtil::IsChildFile(const wchar_t* rootFolder, const wchar_t* file)
 {
-    wstring* f = new wstring(file);
+    const wstring f(file);
 
-    size_t found = f->find(rootFolder);
+    size_t found = f.find(rootFolder);
 
     if(found != string::npos)
     {
@@ -83,4 +83,4 @@ bool FileUtil::IsChildFileOfRoot(const wchar_t* filePath)
 
     delete rootFolder;
     return needed;
-}
\ No newline at end of file
+}