From 72dec21d8f2f42beb463770c0e91719804a18328 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Tue, 28 Nov 2017 18:23:29 +0100 Subject: [PATCH] pointer: fix visibility flag handling Issue #2585 --- repos/os/src/app/pointer/main.cc | 39 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/repos/os/src/app/pointer/main.cc b/repos/os/src/app/pointer/main.cc index 2868ec5db2..48eb640d68 100644 --- a/repos/os/src/app/pointer/main.cc +++ b/repos/os/src/app/pointer/main.cc @@ -183,19 +183,22 @@ void Pointer::Main::_show_default_pointer() void Pointer::Main::_show_shape_pointer(Shape_report &shape_report) { - Nitpicker::Area shape_size { shape_report.width, shape_report.height }; - Nitpicker::Point shape_hot { (int)-shape_report.x_hot, (int)-shape_report.y_hot }; - - try { - _resize_nitpicker_buffer_if_needed(shape_size); - } catch (...) { - error(__func__, ": could not resize the pointer buffer " - "for ", shape_size, " pixels"); - throw; - } + Nitpicker::Area shape_size; + Nitpicker::Point shape_hot; if (shape_report.visible) { + shape_size = Nitpicker::Area(shape_report.width, shape_report.height); + shape_hot = Nitpicker::Point((int)-shape_report.x_hot, (int)-shape_report.y_hot); + + try { + _resize_nitpicker_buffer_if_needed(shape_size); + } catch (...) { + error(__func__, ": could not resize the pointer buffer " + "for ", shape_size, " pixels"); + throw; + } + using namespace Genode; /* import shape into texture */ @@ -256,16 +259,14 @@ void Pointer::Main::_update_pointer() shape_module.read_content(*this, (char*)&shape_report, sizeof(shape_report)); - if (shape_report.visible) { + if (shape_report.visible && + ((shape_report.width == 0) || + (shape_report.height == 0) || + (shape_report.width > MAX_WIDTH) || + (shape_report.height > MAX_HEIGHT))) + throw Genode::Exception(); - if ((shape_report.width == 0) || - (shape_report.height == 0) || - (shape_report.width > MAX_WIDTH) || - (shape_report.height > MAX_HEIGHT)) - throw Genode::Exception(); - - _show_shape_pointer(shape_report); - } + _show_shape_pointer(shape_report); } catch (...) { _rom_registry.release(*this, shape_module);