From c1e181a4070353030ceba911932a8634a34413db Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 29 Nov 2019 14:27:01 +0100 Subject: [PATCH] vbox: handle invalid dataspace exception Fixes #3566 --- repos/ports/src/virtualbox5/frontend/fb.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/repos/ports/src/virtualbox5/frontend/fb.h b/repos/ports/src/virtualbox5/frontend/fb.h index 24e15bde18..dce00fe4eb 100644 --- a/repos/ports/src/virtualbox5/frontend/fb.h +++ b/repos/ports/src/virtualbox5/frontend/fb.h @@ -50,6 +50,8 @@ class Genodefb : void _clear_screen() { + if (!_fb_base) return; + size_t const max_h = Genode::min(_fb_mode.height(), _virtual_fb_mode.height()); size_t const num_pixels = _fb_mode.width() * max_h; memset(_fb_base, 0, num_pixels * _fb_mode.bytes_per_pixel()); @@ -107,11 +109,16 @@ class Genodefb : _fb_mode = mode; - _env.rm().detach(_fb_base); + if (_fb_base) + _env.rm().detach(_fb_base); _adjust_buffer(); - _fb_base = _env.rm().attach(_fb.dataspace()); + try { + _fb_base = _env.rm().attach(_fb.dataspace()); + } catch (...) { + _fb_base = nullptr; + } Unlock(); } @@ -194,6 +201,8 @@ class Genodefb : PRUint32 imageSize, PRUint8 *image) override { + if (!_fb_base) return S_OK; + Lock(); Nitpicker::Area const area_fb = Nitpicker::Area(_fb_mode.width(),