Commit 2cee7ac6 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Don't use CreateFileMapping on a zero length file.

parent 4cd80a36
......@@ -222,22 +222,27 @@ static BOOL BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile)
if (This->hfile == INVALID_HANDLE_VALUE)
return FALSE;
/* create the file mapping object
*/
This->hfilemap = CreateFileMappingA(This->hfile,
NULL,
This->flProtect,
0, 0,
NULL);
This->filesize.s.LowPart = GetFileSize(This->hfile,
&This->filesize.s.HighPart);
if (!This->hfilemap)
if( This->filesize.s.LowPart || This->filesize.s.HighPart )
{
CloseHandle(This->hfile);
return FALSE;
}
/* create the file mapping object
*/
This->hfilemap = CreateFileMappingA(This->hfile,
NULL,
This->flProtect,
0, 0,
NULL);
This->filesize.s.LowPart = GetFileSize(This->hfile,
&This->filesize.s.HighPart);
if (!This->hfilemap)
{
CloseHandle(This->hfile);
return FALSE;
}
}
else
This->hfilemap = NULL;
This->maplist = NULL;
......@@ -420,7 +425,8 @@ void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize)
/*
* close file-mapping object, must be done before call to SetEndFile
*/
CloseHandle(This->hfilemap);
if( This->hfilemap )
CloseHandle(This->hfilemap);
This->hfilemap = 0;
/*
......@@ -662,6 +668,9 @@ static BOOL BIGBLOCKFILE_MapPage(LPBIGBLOCKFILE This, MappedPage *page)
DWORD numBytesToMap;
DWORD desired_access;
if( !This->hfilemap )
return FALSE;
if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart)
numBytesToMap = This->filesize.s.LowPart - lowoffset;
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment