mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-14 03:09:08 +00:00
Fixed: Client crash on bad PNG file from webig download.
--HG-- branch : develop
This commit is contained in:
parent
a7ca4ec3b9
commit
3e95a8b89f
1 changed files with 40 additions and 10 deletions
|
@ -587,6 +587,13 @@ namespace NLGUI
|
||||||
// there is race condition if two browser instances are downloading same file
|
// there is race condition if two browser instances are downloading same file
|
||||||
// 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)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// verify that image is not corrupted
|
||||||
|
uint32 w, h;
|
||||||
|
CBitmap::loadSize(tmpfile, w, h);
|
||||||
|
if (w != 0 && h != 0)
|
||||||
{
|
{
|
||||||
CFile::moveFile(it->dest, tmpfile);
|
CFile::moveFile(it->dest, tmpfile);
|
||||||
for(uint i = 0; i < it->imgs.size(); i++)
|
for(uint i = 0; i < it->imgs.size(); i++)
|
||||||
|
@ -596,6 +603,13 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CFile::moveFile(it->dest, tmpfile);
|
CFile::moveFile(it->dest, tmpfile);
|
||||||
|
@ -4177,11 +4191,19 @@ 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
|
||||||
|
try
|
||||||
|
{
|
||||||
uint32 w, h;
|
uint32 w, h;
|
||||||
CBitmap::loadSize (image, w, h);
|
CBitmap::loadSize (image, w, h);
|
||||||
if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures()))
|
if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures()))
|
||||||
image = "web_del.tga";
|
image = "web_del.tga";
|
||||||
}
|
}
|
||||||
|
catch(const NLMISC::Exception &e)
|
||||||
|
{
|
||||||
|
nlwarning(e.what());
|
||||||
|
image = "web_del.tga";
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@ -4375,12 +4397,20 @@ namespace NLGUI
|
||||||
addImageDownload(normalBitmap, ctrlButton, style);
|
addImageDownload(normalBitmap, ctrlButton, style);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
uint32 w, h;
|
uint32 w, h;
|
||||||
CBitmap::loadSize(normal, w, h);
|
CBitmap::loadSize(normal, w, h);
|
||||||
if (w == 0 || h == 0)
|
if (w == 0 || h == 0)
|
||||||
normal = "web_del.tga";
|
normal = "web_del.tga";
|
||||||
}
|
}
|
||||||
|
catch(const NLMISC::Exception &e)
|
||||||
|
{
|
||||||
|
nlwarning(e.what());
|
||||||
|
normal = "web_del.tga";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue