diff options
author | Niklas Therning <niklas@therning.org> | 2017-05-16 17:46:52 +0300 |
---|---|---|
committer | Niklas Therning <niklas@therning.org> | 2017-05-16 20:35:11 +0300 |
commit | 566eb0ccdb5f5fc22f6280f9cee5f5b082ab5af8 (patch) | |
tree | caf9635194bd8f4463ea79d5a71d3022706b5fb8 /mcs/class/System.Core | |
parent | 8077ff5da774bb771c896d6fdb40740f649975af (diff) |
Fixes a file handle leak in mono_mmap_open_file() on Windows. See
https://bugzilla.xamarin.com/show_bug.cgi?id=56493.
Diffstat (limited to 'mcs/class/System.Core')
-rw-r--r-- | mcs/class/System.Core/Test/System.IO.MemoryMappedFiles/MemoryMappedFileTest.cs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mcs/class/System.Core/Test/System.IO.MemoryMappedFiles/MemoryMappedFileTest.cs b/mcs/class/System.Core/Test/System.IO.MemoryMappedFiles/MemoryMappedFileTest.cs index 9c273b84a59..c192c397fa8 100644 --- a/mcs/class/System.Core/Test/System.IO.MemoryMappedFiles/MemoryMappedFileTest.cs +++ b/mcs/class/System.Core/Test/System.IO.MemoryMappedFiles/MemoryMappedFileTest.cs @@ -451,5 +451,20 @@ namespace MonoTests.System.IO.MemoryMappedFiles { } } + [Test] + public void OpenSameFileMultipleTimes () + { + // See bug 56493 - https://bugzilla.xamarin.com/show_bug.cgi?id=56493 + for (var iteration = 0; iteration < 5; iteration++) { + using (var mmf = MemoryMappedFile.CreateFromFile(fname, FileMode.Open)) { + using (var accessor = mmf.CreateViewAccessor(0, 5)) { + var a = new byte [5]; + accessor.ReadArray (0, a, 0, a.Length); + var s = new string (Array.ConvertAll (a, b => (char) b)); + Assert.AreEqual ("Hello", s); + } + } + } + } } } |