From 74e57c5d9d293858c021d026e618b20fac7284d2 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sun, 12 Jan 2025 03:42:46 +0100 Subject: [PATCH] XdgToplevelIcon: Reserve instead of resize list resize() changes the size of the list, reserve() changes the capacity. If we resize and then append we end up with too many items, some of which are default-constructed (invalid) sizes. Later we use the invalid size to get a pixmap, which will be empty. In QWaylandShmBuffer we then try to mmap the empty pixmap, which fails and we return early, never calling init() and setting mBuffer. In QWaylandXdgToplevelIconV1 we then pass this null buffer to add_buffer, which results in a protocol error Fixes: QTBUG-132727 Pick-to: 6.9 Change-Id: I8f164c43423726367157fa9ce2e3af7a6fd3219c Reviewed-by: David Redondo --- .../shellintegration/xdg-shell/qwaylandxdgtopleveliconv1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1.cpp index f7774f50009..6ecf7e9c990 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1.cpp @@ -79,7 +79,7 @@ void QWaylandXdgToplevelIconManagerV1::setIcon(const QIcon &icon, xdg_toplevel * QList iconSizes = icon.availableSizes(); // if icon has no default size (an SVG) if (iconSizes.isEmpty()) { - iconSizes.resize(mPreferredSizes.size()); + iconSizes.reserve(mPreferredSizes.size()); for (int size : std::as_const(mPreferredSizes)) { iconSizes.append(QSize(size, size)); }