diff --git a/src/framework/platform/win32platform.cpp b/src/framework/platform/win32platform.cpp index 025bcec2..7ba498dc 100644 --- a/src/framework/platform/win32platform.cpp +++ b/src/framework/platform/win32platform.cpp @@ -433,8 +433,10 @@ void Platform::setWindowIcon(const std::string& pngIcon) std::stringstream fin; g_resources.loadFile(pngIcon, fin); if(load_apng(fin, &apng) == 0) { - if(apng.bpp != 4) + if(apng.bpp != 4) { logError("could not set app icon, icon image must have 4 channels"); + free_apng(&apng); + } int n = apng.width * apng.height; std::vector iconData(n); @@ -462,6 +464,8 @@ void Platform::setWindowIcon(const std::string& pngIcon) SendMessage(win32.window, WM_SETICON, ICON_SMALL, (LPARAM)icon); SendMessage(win32.window, WM_SETICON, ICON_BIG, (LPARAM)icon); + + free_apng(&apng); } else logError("could not load app icon"); } diff --git a/src/framework/platform/x11platform.cpp b/src/framework/platform/x11platform.cpp index 8604007d..1bc5affa 100644 --- a/src/framework/platform/x11platform.cpp +++ b/src/framework/platform/x11platform.cpp @@ -704,8 +704,12 @@ void Platform::setWindowIcon(const std::string& pngIcon) std::stringstream fin; g_resources.loadFile(pngIcon, fin); if(load_apng(fin, &apng) == 0) { - if(apng.bpp != 4) + if(apng.bpp != 4) { logError("could not set app icon, icon image must have 4 channels"); + free_apng(&apng); + return; + } + int n = apng.width * apng.height; std::vector iconData(n + 2); iconData[0] = apng.width;