From 9e752359122e9d06722e4dae20f87fa6c3260ed6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 9 Mar 2022 21:13:27 +0100 Subject: [PATCH] Fix crashes on ARM due to window-size overflow On Intel systems ArdourCanvas::COORD_MAX (1.7e+307) was rounded to (gint) -2147483648. gtk+ treats negative window size-requests as 1px. However on ARM, COORD_MAX was truncated to +2147483648, gtk+ limits this to 65535. Most WM/Xwin systems cannot handle windows this large. It also exceeds the max size of cairo [image] surfaces. This issue was introduced in a1c67b4ad7dde95f76b6df5ab75f1f1f447b5dd9 when "natural_size" was removed. Before that change infinitely large canvas had a natural_size of 2x2 px. --- libs/canvas/canvas.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index 1ca149e524..7a269e42c4 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -1559,7 +1559,18 @@ GtkCanvasViewport::on_size_request (Gtk::Requisition* req) _canvas.root()->size_request (width, height); _canvas.request_size (Duple (width, height)); - req->width = width; - req->height = height; -} + /* special case ArdourCanvas::COORD_MAX (really: no size constraint), + * also limit to cairo constraints determined by coordinates of things + * sent to pixman being in 16.16 format. */ + if (width > 32767) { + width = 0; + } + if (height > 32767) { + height = 0; + } + + req->width = std::max(1, width); + req->height = std::max(1, height); + +}