From 81248f3899d7134298f79f4bd7dbc04ddc523de7 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Wed, 20 Oct 2021 09:04:20 +0100 Subject: [PATCH] dotnet: FileSystemHost: zero-init allocations made using Marshal.AllocHGlobal --- src/dotnet/FileSystemHost.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dotnet/FileSystemHost.cs b/src/dotnet/FileSystemHost.cs index d3423057..4723a494 100644 --- a/src/dotnet/FileSystemHost.cs +++ b/src/dotnet/FileSystemHost.cs @@ -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); }