Index: compiler-rt/lib/scudo/standalone/fuchsia.cpp =================================================================== --- compiler-rt/lib/scudo/standalone/fuchsia.cpp +++ compiler-rt/lib/scudo/standalone/fuchsia.cpp @@ -57,8 +57,9 @@ 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); + zx_handle_t Vmar = _zx_vmar_root_self(); + if (Data && Data->Vmar != ZX_HANDLE_INVALID) + Vmar = Data->Vmar; zx_status_t Status; zx_handle_t Vmo; @@ -126,7 +127,9 @@ 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(); + zx_handle_t Vmar = _zx_vmar_root_self(); + if (Data && Data->Vmar != ZX_HANDLE_INVALID) + Vmar = Data->Vmar; const zx_status_t Status = _zx_vmar_unmap(Vmar, reinterpret_cast(Addr), Size); if (UNLIKELY(Status != ZX_OK))