From 044eb85872e0771c397826d72098b76c0d74c8e8 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Thu, 1 Nov 2012 22:23:00 +0100 Subject: [PATCH] Fixed Xlib potential errors --- src/SFML/Window/Linux/WindowImplX11.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SFML/Window/Linux/WindowImplX11.cpp b/src/SFML/Window/Linux/WindowImplX11.cpp index fd17b789..3cf2293a 100644 --- a/src/SFML/Window/Linux/WindowImplX11.cpp +++ b/src/SFML/Window/Linux/WindowImplX11.cpp @@ -323,8 +323,8 @@ void WindowImplX11::setTitle(const std::string& title) void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8* pixels) { // X11 wants BGRA pixels : swap red and blue channels - // Note : this memory will never be freed, but it seems to cause a bug on exit if I do so - Uint8* iconPixels = new Uint8[width * height * 4]; + // Note: this memory will be freed by XDestroyImage + Uint8* iconPixels = static_cast(std::malloc(width * height * 4)); for (std::size_t i = 0; i < width * height; ++i) { iconPixels[i * 4 + 0] = pixels[i * 4 + 2]; @@ -464,6 +464,8 @@ void WindowImplX11::initialize() { // Make sure the "last key release" is initialized with invalid values m_lastKeyReleaseEvent.type = -1; + m_lastKeyReleaseEvent.xkey.keycode = 0; + m_lastKeyReleaseEvent.xkey.time = 0; // Get the atom defining the close event m_atomClose = XInternAtom(m_display, "WM_DELETE_WINDOW", false);