1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Fix problems with handling return value of mmap() in lsm_unix.c (mmap() returns MAP_FAILED on error, not NULL).

FossilOrigin-Name: da06168c09df5c0e8e10d0f9618e69217d4c0173a8199660bad2805f009d7b08
This commit is contained in:
dan
2020-06-22 16:02:06 +00:00
parent a764709bf3
commit 3259295533
3 changed files with 16 additions and 8 deletions

View File

@@ -228,6 +228,10 @@ static int lsmPosixOsRemap(
}
p->pMap = mmap(0, iSz, PROT_READ|PROT_WRITE, MAP_SHARED, p->fd, 0);
if( p->pMap==MAP_FAILED ){
p->pMap = 0;
return LSM_IOERR_BKPT;
}
p->nMap = iSz;
}
@@ -413,7 +417,10 @@ static int lsmPosixOsShmMap(lsm_file *pFile, int iChunk, int sz, void **ppShm){
p->apShm[iChunk] = mmap(0, LSM_SHM_CHUNK_SIZE,
PROT_READ|PROT_WRITE, MAP_SHARED, p->shmfd, iChunk*LSM_SHM_CHUNK_SIZE
);
if( p->apShm[iChunk]==0 ) return LSM_IOERR_BKPT;
if( p->apShm[iChunk]==MAP_FAILED ){
p->apShm[iChunk] = 0;
return LSM_IOERR_BKPT;
}
}
*ppShm = p->apShm[iChunk];