diff --git a/distribution/changelog.txt b/distribution/changelog.txt index a13d8f6700..eccac222c8 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -6,6 +6,7 @@ - Improved: [#26099] The ride visiblity cheat has been moved into the ride colour/appearance tab. - Improved: [#26862] Add a Liquid Glass app icon for macOS 26 and later. - Improved: [#26936] Rain is now drawn next to the top toolbar, but only when it is centred. +- Fix: [#21632] [Plugin] Crash when loading custom image larger than 300 by 300 pixels. - Fix: [#25169] The convert command strips custom objects from the resulting park. - Fix: [#26811] Crash when a ride points to a non-existing station object. - Fix: [#26816] Water rides ignore zero clearances, preventing adjacent terrain modifications and building them anywhere. diff --git a/src/openrct2-ui/scripting/ScImageManager.hpp b/src/openrct2-ui/scripting/ScImageManager.hpp index 82bb29764c..b8e7d05b71 100644 --- a/src/openrct2-ui/scripting/ScImageManager.hpp +++ b/src/openrct2-ui/scripting/ScImageManager.hpp @@ -156,7 +156,7 @@ namespace OpenRCT2::Scripting { JSSetPixelData(ctx, id, pixelData); } - catch (const std::runtime_error& e) + catch (const std::exception& e) { JS_ThrowInternalError(ctx, "%s", e.what()); return JS_EXCEPTION; diff --git a/src/openrct2/core/Imaging.cpp b/src/openrct2/core/Imaging.cpp index 9625937e87..5a9873ef7c 100644 --- a/src/openrct2/core/Imaging.cpp +++ b/src/openrct2/core/Imaging.cpp @@ -115,7 +115,10 @@ namespace OpenRCT2::Imaging if (colourType == PNG_COLOR_TYPE_RGB) { // 24-bit PNG (no alpha) - Guard::Assert(rowBytes == pngWidth * 3, GUARD_LINE); + if (rowBytes != pngWidth * 3) + { + throw std::runtime_error("PNG must have 24-bit colours in RGB mode. "); + } for (png_uint_32 i = 0; i < pngHeight; i++) { auto src = rowPointers[i]; @@ -131,7 +134,10 @@ namespace OpenRCT2::Imaging else if (bitDepth == 8 && !expandTo32) { // 8-bit paletted or greyscale - Guard::Assert(rowBytes == pngWidth, GUARD_LINE); + if (rowBytes != pngWidth) + { + throw std::runtime_error("PNG must be 8-bit paletted when using \"keep\" palette. "); + } for (png_uint_32 i = 0; i < pngHeight; i++) { std::copy_n(rowPointers[i], rowBytes, dst); @@ -141,7 +147,10 @@ namespace OpenRCT2::Imaging else { // 32-bit PNG (with alpha) - Guard::Assert(rowBytes == pngWidth * 4, GUARD_LINE); + if (rowBytes != pngWidth * 4) + { + throw std::runtime_error("PNG must either have 8-bit paletted, or 24-bit/32-bit full colour data. "); + } for (png_uint_32 i = 0; i < pngHeight; i++) { std::copy_n(rowPointers[i], rowBytes, dst);