mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-10 01:09:34 +00:00
Fixed: Client crash on bad PNG file from webig download.
This commit is contained in:
parent
44db61b463
commit
9aae361c7b
1 changed files with 40 additions and 10 deletions
|
@ -588,11 +588,25 @@ namespace NLGUI
|
||||||
// second instance deletes first tmpfile and creates new file for itself.
|
// second instance deletes first tmpfile and creates new file for itself.
|
||||||
if (CFile::getFileSize(tmpfile) > 0)
|
if (CFile::getFileSize(tmpfile) > 0)
|
||||||
{
|
{
|
||||||
CFile::moveFile(it->dest, tmpfile);
|
try
|
||||||
for(uint i = 0; i < it->imgs.size(); i++)
|
|
||||||
{
|
{
|
||||||
setImage(it->imgs[i].Image, it->dest);
|
// verify that image is not corrupted
|
||||||
setImageSize(it->imgs[i].Image, it->imgs[i].Style);
|
uint32 w, h;
|
||||||
|
CBitmap::loadSize(tmpfile, w, h);
|
||||||
|
if (w != 0 && h != 0)
|
||||||
|
{
|
||||||
|
CFile::moveFile(it->dest, tmpfile);
|
||||||
|
for(uint i = 0; i < it->imgs.size(); i++)
|
||||||
|
{
|
||||||
|
setImage(it->imgs[i].Image, it->dest);
|
||||||
|
setImageSize(it->imgs[i].Image, it->imgs[i].Style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(const NLMISC::Exception &e)
|
||||||
|
{
|
||||||
|
// exception message has .tmp file name, so keep it for further analysis
|
||||||
|
nlwarning("Invalid image (%s): %s", it->url.c_str(), e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4177,10 +4191,18 @@ namespace NLGUI
|
||||||
if (!reloadImg && lookupLocalFile (finalUrl, image.c_str(), false))
|
if (!reloadImg && lookupLocalFile (finalUrl, image.c_str(), false))
|
||||||
{
|
{
|
||||||
// don't display image that are not power of 2
|
// don't display image that are not power of 2
|
||||||
uint32 w, h;
|
try
|
||||||
CBitmap::loadSize (image, w, h);
|
{
|
||||||
if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures()))
|
uint32 w, h;
|
||||||
|
CBitmap::loadSize (image, w, h);
|
||||||
|
if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures()))
|
||||||
|
image = "web_del.tga";
|
||||||
|
}
|
||||||
|
catch(const NLMISC::Exception &e)
|
||||||
|
{
|
||||||
|
nlwarning(e.what());
|
||||||
image = "web_del.tga";
|
image = "web_del.tga";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4376,10 +4398,18 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint32 w, h;
|
try
|
||||||
CBitmap::loadSize(normal, w, h);
|
{
|
||||||
if (w == 0 || h == 0)
|
uint32 w, h;
|
||||||
|
CBitmap::loadSize(normal, w, h);
|
||||||
|
if (w == 0 || h == 0)
|
||||||
|
normal = "web_del.tga";
|
||||||
|
}
|
||||||
|
catch(const NLMISC::Exception &e)
|
||||||
|
{
|
||||||
|
nlwarning(e.what());
|
||||||
normal = "web_del.tga";
|
normal = "web_del.tga";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue