X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Ffile-mmap-windows.c;h=59abd6686ffe192285513af90cccac7c23becd7a;hb=HEAD;hp=3cc9124c0854ccf6626e244329df27bd8c5e90ae;hpb=ced1dce6fb73eb9e57d31b30ec3e8d8d971a18dd;p=mono.git diff --git a/mono/metadata/file-mmap-windows.c b/mono/metadata/file-mmap-windows.c index 3cc9124c085..59abd6686ff 100644 --- a/mono/metadata/file-mmap-windows.c +++ b/mono/metadata/file-mmap-windows.c @@ -1,5 +1,6 @@ -/* - * file-mmap-windows.c: MemoryMappedFile internal calls for Windows +/** + * \file + * MemoryMappedFile internal calls for Windows * * Copyright 2016 Microsoft * Licensed under the MIT license. See LICENSE file in the project root for full license information. @@ -139,7 +140,7 @@ static void *open_handle (void *handle, MonoString *mapName, int mode, gint64 *c HANDLE result = NULL; if (handle == INVALID_HANDLE_VALUE) { - if (*capacity <= 0) { + if (*capacity <= 0 && mode != FILE_MODE_OPEN) { *error = CAPACITY_MUST_BE_POSITIVE; return NULL; } @@ -270,6 +271,8 @@ void *mono_mmap_open_file (MonoString *path, int mode, MonoString *mapName, gint result = open_handle (hFile, mapName, mode, capacity, access, options, error); done: + if (hFile != INVALID_HANDLE_VALUE) + CloseHandle (hFile); if (!result && delete_on_error) DeleteFileW (w_path); if (w_path)