dotnet: FileSystemHost: zero-init allocations made using Marshal.AllocHGlobal

This commit is contained in:
Bill Zissimopoulos 2021-10-20 09:04:20 +01:00
parent a4d7aee6f5
commit 81248f3899
No known key found for this signature in database
GPG Key ID: 3D4F95D52C7B3EA3

View File

@ -1448,6 +1448,9 @@ namespace Fsp
_FileSystemInterface.SetEa = SetEa;
_FileSystemInterfacePtr = Marshal.AllocHGlobal(FileSystemInterface.Size);
/* Marshal.AllocHGlobal does not zero memory; we must do it ourselves! */
for (int Offset = 0; FileSystemInterface.Size > Offset; Offset += IntPtr.Size)
Marshal.WriteIntPtr(_FileSystemInterfacePtr, Offset, IntPtr.Zero);
Marshal.StructureToPtr(_FileSystemInterface, _FileSystemInterfacePtr, false);
}