vbox: handle invalid dataspace exception

Fixes #3566
This commit is contained in:
Alexander Boettcher 2019-11-29 14:27:01 +01:00 committed by Christian Helmuth
parent 8f71c90ca8
commit c1e181a407

View File

@ -50,6 +50,8 @@ class Genodefb :
void _clear_screen() void _clear_screen()
{ {
if (!_fb_base) return;
size_t const max_h = Genode::min(_fb_mode.height(), _virtual_fb_mode.height()); size_t const max_h = Genode::min(_fb_mode.height(), _virtual_fb_mode.height());
size_t const num_pixels = _fb_mode.width() * max_h; size_t const num_pixels = _fb_mode.width() * max_h;
memset(_fb_base, 0, num_pixels * _fb_mode.bytes_per_pixel()); memset(_fb_base, 0, num_pixels * _fb_mode.bytes_per_pixel());
@ -107,11 +109,16 @@ class Genodefb :
_fb_mode = mode; _fb_mode = mode;
_env.rm().detach(_fb_base); if (_fb_base)
_env.rm().detach(_fb_base);
_adjust_buffer(); _adjust_buffer();
_fb_base = _env.rm().attach(_fb.dataspace()); try {
_fb_base = _env.rm().attach(_fb.dataspace());
} catch (...) {
_fb_base = nullptr;
}
Unlock(); Unlock();
} }
@ -194,6 +201,8 @@ class Genodefb :
PRUint32 imageSize, PRUint32 imageSize,
PRUint8 *image) override PRUint8 *image) override
{ {
if (!_fb_base) return S_OK;
Lock(); Lock();
Nitpicker::Area const area_fb = Nitpicker::Area(_fb_mode.width(), Nitpicker::Area const area_fb = Nitpicker::Area(_fb_mode.width(),