Fix potential leaks using SHGetKnownFolderPath
Documentation for `SHGetKnownFolderPath` remarks that the `PWSTR` parameter should always be freed with `CoTaskMemFree` even if it succeeds or not. Pull Request: https://projects.blender.org/blender/blender/pulls/111128
This commit is contained in:
committed by
Germano Cavalcante
parent
0c7496f74d
commit
84718feb4b
@@ -35,7 +35,7 @@ const char *GHOST_SystemPathsWin32::getSystemDir(int, const char *versionstr) co
|
||||
strcat(knownpath, versionstr);
|
||||
return knownpath;
|
||||
}
|
||||
|
||||
CoTaskMemFree(knownpath_16);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ const char *GHOST_SystemPathsWin32::getUserDir(int, const char *versionstr) cons
|
||||
strcat(knownpath, versionstr);
|
||||
return knownpath;
|
||||
}
|
||||
|
||||
CoTaskMemFree(knownpath_16);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,6 @@ const char *GHOST_SystemPathsWin32::getUserSpecialDir(GHOST_TUserSpecialDirTypes
|
||||
CoTaskMemFree(knownpath_16);
|
||||
return knownpath;
|
||||
}
|
||||
|
||||
CoTaskMemFree(knownpath_16);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -234,9 +234,9 @@ static void fsmenu_add_windows_folder(FSMenu *fsmenu,
|
||||
char line[FILE_MAXDIR];
|
||||
if (SHGetKnownFolderPath(rfid, 0, nullptr, &pPath) == S_OK) {
|
||||
BLI_strncpy_wchar_as_utf8(line, pPath, FILE_MAXDIR);
|
||||
CoTaskMemFree(pPath);
|
||||
fsmenu_insert_entry(fsmenu, category, line, name, icon, flag);
|
||||
}
|
||||
CoTaskMemFree(pPath);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user