Don't call function pointers when they're NULL (fixes a segfault bug that occurs when a resource type without release function couldn't be loaded)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4896 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
46805bb32f
commit
31fda8026b
|
@ -463,7 +463,10 @@ BOOL resLoadFile(const char *pType, const char *pFile)
|
|||
{
|
||||
debug(LOG_ERROR, "resLoadFile: The load function for resource type \"%s\" failed for file \"%s\"", pType, pFile);
|
||||
FreeResourceFile(Resource);
|
||||
if (psT->release != NULL)
|
||||
{
|
||||
psT->release(pData);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -475,7 +478,10 @@ BOOL resLoadFile(const char *pType, const char *pFile)
|
|||
if (!psT->fileLoad(aFileName, &pData))
|
||||
{
|
||||
debug(LOG_ERROR, "resLoadFile: The load function for resource type \"%s\" failed for file \"%s\"", pType, pFile);
|
||||
if (psT->release != NULL)
|
||||
{
|
||||
psT->release(pData);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -493,8 +499,11 @@ BOOL resLoadFile(const char *pType, const char *pFile)
|
|||
// LastResourceFilename may have been changed (e.g. by TEXPAGE loading)
|
||||
psRes = resDataInit( GetLastResourceFilename(), HashStringIgnoreCase(GetLastResourceFilename()), pData, resBlockID );
|
||||
if (!psRes)
|
||||
{
|
||||
if (psT->release != NULL)
|
||||
{
|
||||
psT->release(pData);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue