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;
}
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)