From 06db7f074e595f22be53a0cfc448011b88559ec4 Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Thu, 20 Jan 2022 11:58:01 +0000 Subject: [PATCH] Linux: Fix a out-of-bounds memory write when copying text to the clipboard --- .../juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp b/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp index 3911d1d59b..c0e7b8dc26 100644 --- a/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp +++ b/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp @@ -1361,8 +1361,10 @@ namespace ClipboardHelpers { // another application wants to know what we are able to send numDataItems = 2; - propertyFormat = 32; // atoms are 32-bit - data.calloc (numDataItems * 4); + constexpr size_t atomSize = sizeof (Atom); + static_assert (atomSize == 8, "Atoms are 32-bit"); + propertyFormat = atomSize * 4; + data.calloc (numDataItems * atomSize); auto* dataAtoms = unalignedPointerCast (data.getData());