diff --git a/repos/os/src/server/nitpicker/session_component.cc b/repos/os/src/server/nitpicker/session_component.cc index 3ab27fe6b3..59f5c9d27c 100644 --- a/repos/os/src/server/nitpicker/session_component.cc +++ b/repos/os/src/server/nitpicker/session_component.cc @@ -345,16 +345,22 @@ void Session_component::destroy_view(View_handle handle) */ for (Session_view_list_elem *v = _view_list.first(); v; v = v->next()) { - try { - View_component &view = *static_cast(v); - if (_view_handle_registry.has_handle(view, handle)) { - _destroy_view(view); - break; - } - } catch (View_handle_registry::Lookup_failed) { } - } + auto handle_matches = [&] (View_component const &view) + { + try { return _view_handle_registry.has_handle(view, handle); } - _view_handle_registry.free(handle); + /* 'Handle_registry::has_handle' may throw */ + catch (...) { return false; }; + }; + + View_component &view = *static_cast(v); + + if (handle_matches(view)) { + _destroy_view(view); + _view_handle_registry.free(handle); + break; + } + } } diff --git a/repos/os/src/test/nitpicker/test.cc b/repos/os/src/test/nitpicker/test.cc index 9fe6e3f5ee..49e6125112 100644 --- a/repos/os/src/test/nitpicker/test.cc +++ b/repos/os/src/test/nitpicker/test.cc @@ -161,6 +161,14 @@ void Component::construct(Genode::Env &env) return; } + /* bad-case test */ + { + /* issue #3232 */ + Nitpicker::Session::View_handle handle { nitpicker.create_view() }; + nitpicker.destroy_view(handle); + nitpicker.destroy_view(handle); + } + Genode::Attached_dataspace fb_ds( env.rm(), nitpicker.framebuffer()->dataspace()); @@ -169,7 +177,7 @@ void Component::construct(Genode::Env &env) unsigned char *input_mask = CONFIG_ALPHA ? alpha + scr_w*scr_h : 0; /* - * Paint some crap into pixel buffer, fill alpha channel and input-mask buffer + * Paint into pixel buffer, fill alpha channel and input-mask buffer * * Input should refer to the view if the alpha value is more than 50%. */