[scudo][Fuchsia] Don't assume MapPlatformData::Vmar is valid

After https://reviews.llvm.org/D129237, the assumption
that any non-null data contains a valid vmar handle is no
longer true. Generally this code here needs cleanup, but
in the meantime this fixes errors on Fuchsia.

Differential Revision: https://reviews.llvm.org/D129331
This commit is contained in:
Alex Brachet
2022-07-11 17:39:44 +00:00
parent d0751c9725
commit c823cbf699

View File

@@ -57,8 +57,7 @@ void *map(void *Addr, uptr Size, const char *Name, uptr Flags,
if (Flags & MAP_NOACCESS)
return allocateVmar(Size, Data, AllowNoMem);
const zx_handle_t Vmar = Data ? Data->Vmar : _zx_vmar_root_self();
CHECK_NE(Vmar, ZX_HANDLE_INVALID);
const zx_handle_t Vmar = (Data && Data->Vmar != ZX_HANDLE_INVALID) ? Data->Vmar : _zx_vmar_root_self();
zx_status_t Status;
zx_handle_t Vmo;
@@ -126,7 +125,7 @@ void unmap(void *Addr, uptr Size, uptr Flags, MapPlatformData *Data) {
CHECK_EQ(_zx_vmar_destroy(Vmar), ZX_OK);
CHECK_EQ(_zx_handle_close(Vmar), ZX_OK);
} else {
const zx_handle_t Vmar = Data ? Data->Vmar : _zx_vmar_root_self();
const zx_handle_t Vmar = (Data && Data->Vmar != ZX_HANDLE_INVALID) ? Data->Vmar : _zx_vmar_root_self();
const zx_status_t Status =
_zx_vmar_unmap(Vmar, reinterpret_cast<uintptr_t>(Addr), Size);
if (UNLIKELY(Status != ZX_OK))