if (!tres)
return tres;
- len = strlen (tres) + 1;
+ /*
+ * mono_string_to_utf8_checked() returns a memory area at least as large as the size of the
+ * MonoString, even if it contains NULL characters. The copy we allocate here has to be equally
+ * large.
+ */
+ len = MAX (strlen (tres) + 1, string->length);
ret = ves_icall_System_Runtime_InteropServices_Marshal_AllocHGlobal (len);
memcpy (ret, tres, len);
g_free (tres);
{
gboolean success = FALSE;
PACL pDACL = NULL;
+ PSECURITY_DESCRIPTOR pSD = NULL;
PSID pEveryoneSid = NULL;
- DWORD dwRes = GetNamedSecurityInfoW (path, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, &pDACL, NULL, NULL);
+ DWORD dwRes = GetNamedSecurityInfoW (path, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, &pDACL, NULL, &pSD);
if (dwRes != ERROR_SUCCESS)
return FALSE;
/* Note: we don't need to check our own access -
we'll know soon enough when reading the file */
- if (pDACL)
- LocalFree (pDACL);
+ if (pSD)
+ LocalFree (pSD);
return success;
}