Catch error when decompressing

Make sure we catch errors when thrown by zlib

Fixes https://gitlab.com/kicad/code/kicad/issues/5376
This commit is contained in:
Seth Hillbrand 2020-08-26 14:18:54 -07:00
parent 3e754e0378
commit f1b1e59cf0
3 changed files with 33 additions and 3 deletions

View File

@ -481,7 +481,17 @@ bool readSTEPZ( Handle(TDocStd_Document)& m_doc, const char* aFileName )
char *buffer = new char[size];
ifile.Read( buffer, size);
std::string expanded = gzip::decompress( buffer, size );
std::string expanded;
try
{
expanded = gzip::decompress( buffer, size );
}
catch(...)
{
delete[] buffer;
return false;
}
delete[] buffer;

View File

@ -187,7 +187,17 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline )
char *buffer = new char[size];
ifile.Read( buffer, size);
std::string expanded = gzip::decompress( buffer, size );
std::string expanded;
try
{
expanded = gzip::decompress( buffer, size );
}
catch(...)
{
delete[] buffer;
return nullptr;
}
delete[] buffer;

View File

@ -995,7 +995,17 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TRIPLET aScale, TDF_L
char *buffer = new char[size];
ifile.Read( buffer, size);
std::string expanded = gzip::decompress( buffer, size );
std::string expanded;
try
{
expanded = gzip::decompress( buffer, size );
}
catch(...)
{
delete[] buffer;
return false;
}
delete[] buffer;