Util: Failed file mapping should return NULL on POSIX

This commit is contained in:
Vicki Pfau 2022-02-16 22:57:25 -08:00
parent 7752c0c849
commit c22aaadf7f
2 changed files with 6 additions and 1 deletions

View File

@ -9,6 +9,7 @@ Other fixes:
- FFmpeg: Fix crash when encoding audio with some containers
- FFmpeg: Fix GIF recording (fixes mgba.io/i/2393)
- GB, GBA: Save writeback-pending masked saves on unload (fixes mgba.io/i/2396)
- VFS: Failed file mapping should return NULL on POSIX
Misc:
- Qt: Enable -b for Boot BIOS menu option (fixes mgba.io/i/2074)

View File

@ -132,7 +132,11 @@ static void* _vfdMap(struct VFile* vf, size_t size, int flags) {
if (flags & MAP_WRITE) {
mmapFlags = MAP_SHARED;
}
return mmap(0, size, PROT_READ | PROT_WRITE, mmapFlags, vfd->fd, 0);
void* mapped = mmap(0, size, PROT_READ | PROT_WRITE, mmapFlags, vfd->fd, 0);
if (mapped == MAP_FAILED) {
return NULL;
}
return mapped;
}
static void _vfdUnmap(struct VFile* vf, void* memory, size_t size) {