Don't use CreateFileMapping on a zero length file.
This commit is contained in:
parent
4cd80a3637
commit
2cee7ac6d9
|
@ -222,23 +222,28 @@ static BOOL BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile)
|
||||||
if (This->hfile == INVALID_HANDLE_VALUE)
|
if (This->hfile == INVALID_HANDLE_VALUE)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* create the file mapping object
|
|
||||||
*/
|
|
||||||
This->hfilemap = CreateFileMappingA(This->hfile,
|
|
||||||
NULL,
|
|
||||||
This->flProtect,
|
|
||||||
0, 0,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (!This->hfilemap)
|
|
||||||
{
|
|
||||||
CloseHandle(This->hfile);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
This->filesize.s.LowPart = GetFileSize(This->hfile,
|
This->filesize.s.LowPart = GetFileSize(This->hfile,
|
||||||
&This->filesize.s.HighPart);
|
&This->filesize.s.HighPart);
|
||||||
|
|
||||||
|
if( This->filesize.s.LowPart || This->filesize.s.HighPart )
|
||||||
|
{
|
||||||
|
/* create the file mapping object
|
||||||
|
*/
|
||||||
|
This->hfilemap = CreateFileMappingA(This->hfile,
|
||||||
|
NULL,
|
||||||
|
This->flProtect,
|
||||||
|
0, 0,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (!This->hfilemap)
|
||||||
|
{
|
||||||
|
CloseHandle(This->hfile);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
This->hfilemap = NULL;
|
||||||
|
|
||||||
This->maplist = NULL;
|
This->maplist = NULL;
|
||||||
|
|
||||||
TRACE("file len %lu\n", This->filesize.s.LowPart);
|
TRACE("file len %lu\n", This->filesize.s.LowPart);
|
||||||
|
@ -420,7 +425,8 @@ void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize)
|
||||||
/*
|
/*
|
||||||
* close file-mapping object, must be done before call to SetEndFile
|
* close file-mapping object, must be done before call to SetEndFile
|
||||||
*/
|
*/
|
||||||
CloseHandle(This->hfilemap);
|
if( This->hfilemap )
|
||||||
|
CloseHandle(This->hfilemap);
|
||||||
This->hfilemap = 0;
|
This->hfilemap = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -662,6 +668,9 @@ static BOOL BIGBLOCKFILE_MapPage(LPBIGBLOCKFILE This, MappedPage *page)
|
||||||
DWORD numBytesToMap;
|
DWORD numBytesToMap;
|
||||||
DWORD desired_access;
|
DWORD desired_access;
|
||||||
|
|
||||||
|
if( !This->hfilemap )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart)
|
if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart)
|
||||||
numBytesToMap = This->filesize.s.LowPart - lowoffset;
|
numBytesToMap = This->filesize.s.LowPart - lowoffset;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue