mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Formspec: prevent infinite loop caused by negative background9[] size (#13624)
This commit is contained in:
parent
869df17ddf
commit
078bd95a49
@ -78,6 +78,7 @@ video::ITexture *guiScalingResizeCached(video::IVideoDriver *driver,
|
||||
{
|
||||
if (src == NULL)
|
||||
return src;
|
||||
|
||||
if (!g_settings->getBool("gui_scaling_filter"))
|
||||
return src;
|
||||
|
||||
@ -114,6 +115,14 @@ video::ITexture *guiScalingResizeCached(video::IVideoDriver *driver,
|
||||
|
||||
// Create a new destination image and scale the source into it.
|
||||
imageCleanTransparent(srcimg, 0);
|
||||
|
||||
if (destrect.getWidth() <= 0 || destrect.getHeight() <= 0) {
|
||||
errorstream << "Attempted to scale texture to invalid size " << scalename.c_str() << std::endl;
|
||||
// Avoid log spam by reusing and displaying the original texture
|
||||
src->grab();
|
||||
g_txrCache[scalename] = src;
|
||||
return src;
|
||||
}
|
||||
video::IImage *destimg = driver->createImage(src->getColorFormat(),
|
||||
core::dimension2d<u32>((u32)destrect.getWidth(),
|
||||
(u32)destrect.getHeight()));
|
||||
@ -160,6 +169,10 @@ void draw2DImageFilterScaled(video::IVideoDriver *driver, video::ITexture *txr,
|
||||
const core::rect<s32> *cliprect, const video::SColor *const colors,
|
||||
bool usealpha)
|
||||
{
|
||||
// 9-sliced images might calculate negative texture dimensions. Skip them.
|
||||
if (destrect.getWidth() <= 0 || destrect.getHeight() <= 0)
|
||||
return;
|
||||
|
||||
// Attempt to pre-scale image in software in high quality.
|
||||
video::ITexture *scaled = guiScalingResizeCached(driver, txr, srcrect, destrect);
|
||||
if (scaled == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user