diff options
author | James Cowgill <james410@cowgill.org.uk> | 2016-12-30 18:47:33 +0000 |
---|---|---|
committer | James Cowgill <james410@cowgill.org.uk> | 2016-12-30 18:47:33 +0000 |
commit | a5ae4901142eb30c699419261ef95970bd876110 (patch) | |
tree | f2dd0f57ebafb56f0974400a67dbb700721d29d9 | |
parent | 7d84a6d0f63f1d71f7f18fb6a5de3fa6d1fc11e0 (diff) |
Fix segfaults triggered by sf::Window::setIcon
Closes: #849750
-rw-r--r-- | debian/patches/07_fix-crashing-in-sf-Window-setIcon.patch | 84 | ||||
-rw-r--r-- | debian/patches/series | 1 |
2 files changed, 85 insertions, 0 deletions
diff --git a/debian/patches/07_fix-crashing-in-sf-Window-setIcon.patch b/debian/patches/07_fix-crashing-in-sf-Window-setIcon.patch new file mode 100644 index 0000000..729760d --- /dev/null +++ b/debian/patches/07_fix-crashing-in-sf-Window-setIcon.patch @@ -0,0 +1,84 @@ +From 8c62390ca211e0dbc7b9233f41ba53952b80154c Mon Sep 17 00:00:00 2001 +From: binary1248 <binary1248@hotmail.com> +Date: Sat, 26 Nov 2016 15:51:24 +0100 +Subject: [PATCH] Fixed Xlib crashing in sf::Window:setIcon because it expects + the element data type passed to XChangeProperty to be unsigned long + (architecture dependent 32-bit or 64-bit) instead of sf::Uint32 (architecture + independent 32-bit) (#1168). Also adjusted other occurrences of wrong types + passed to XChangeProperty with format set to 32. + +[jcowgill: this is upstream PR https://github.com/SFML/SFML/pull/1171] + +--- + src/SFML/Window/Unix/WindowImplX11.cpp | 30 ++++++++++++++++-------------- + 1 file changed, 16 insertions(+), 14 deletions(-) + +diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp +index 530bea50..a17d3d31 100644 +--- a/src/SFML/Window/Unix/WindowImplX11.cpp ++++ b/src/SFML/Window/Unix/WindowImplX11.cpp +@@ -777,10 +777,10 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8 + Uint8* iconPixels = static_cast<Uint8*>(std::malloc(width * height * 4)); + for (std::size_t i = 0; i < width * height; ++i) + { +- iconPixels[8 + i * 4 + 0] = pixels[i * 4 + 2]; +- iconPixels[8 + i * 4 + 1] = pixels[i * 4 + 1]; +- iconPixels[8 + i * 4 + 2] = pixels[i * 4 + 0]; +- iconPixels[8 + i * 4 + 3] = pixels[i * 4 + 3]; ++ iconPixels[i * 4 + 0] = pixels[i * 4 + 2]; ++ iconPixels[i * 4 + 1] = pixels[i * 4 + 1]; ++ iconPixels[i * 4 + 2] = pixels[i * 4 + 0]; ++ iconPixels[i * 4 + 3] = pixels[i * 4 + 3]; + } + + // Create the icon pixmap +@@ -835,18 +835,20 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8 + + // ICCCM wants BGRA pixels: swap red and blue channels + // ICCCM also wants the first 2 unsigned 32-bit values to be width and height +- std::vector<Uint8> icccmIconPixels(8 + width * height * 4, 0); ++ std::vector<unsigned long> icccmIconPixels(2 + width * height, 0); ++ unsigned long* ptr = &icccmIconPixels[0]; ++ ++ *ptr++ = width; ++ *ptr++ = height; ++ + for (std::size_t i = 0; i < width * height; ++i) + { +- icccmIconPixels[8 + i * 4 + 0] = pixels[i * 4 + 2]; +- icccmIconPixels[8 + i * 4 + 1] = pixels[i * 4 + 1]; +- icccmIconPixels[8 + i * 4 + 2] = pixels[i * 4 + 0]; +- icccmIconPixels[8 + i * 4 + 3] = pixels[i * 4 + 3]; ++ *ptr++ = (pixels[i * 4 + 2] << 0 ) | ++ (pixels[i * 4 + 1] << 8 ) | ++ (pixels[i * 4 + 0] << 16) | ++ (pixels[i * 4 + 3] << 24); + } + +- reinterpret_cast<Uint32*>(&icccmIconPixels[0])[0] = width; +- reinterpret_cast<Uint32*>(&icccmIconPixels[0])[1] = height; +- + Atom netWmIcon = getAtom("_NET_WM_ICON"); + + XChangeProperty(m_display, +@@ -1147,7 +1149,7 @@ void WindowImplX11::switchToFullscreen() + + if (netWmBypassCompositor) + { +- static const Uint32 bypassCompositor = 1; ++ static const unsigned long bypassCompositor = 1; + + XChangeProperty(m_display, + m_window, +@@ -1226,7 +1228,7 @@ void WindowImplX11::setProtocols() + + if (netWmPing && netWmPid) + { +- uint32_t pid = getpid(); ++ const long pid = getpid(); + + XChangeProperty(m_display, + m_window, +-- +2.11.0 + diff --git a/debian/patches/series b/debian/patches/series index 06d8ed1..275896b 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,3 +2,4 @@ 04_remove-googleapi-css.patch 05_build-doc-once.patch 06_pkgconfig-freebsd.patch +07_fix-crashing-in-sf-Window-setIcon.patch |