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);
|
debug(LOG_ERROR, "resLoadFile: The load function for resource type \"%s\" failed for file \"%s\"", pType, pFile);
|
||||||
FreeResourceFile(Resource);
|
FreeResourceFile(Resource);
|
||||||
psT->release(pData);
|
if (psT->release != NULL)
|
||||||
|
{
|
||||||
|
psT->release(pData);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +478,10 @@ BOOL resLoadFile(const char *pType, const char *pFile)
|
||||||
if (!psT->fileLoad(aFileName, &pData))
|
if (!psT->fileLoad(aFileName, &pData))
|
||||||
{
|
{
|
||||||
debug(LOG_ERROR, "resLoadFile: The load function for resource type \"%s\" failed for file \"%s\"", pType, pFile);
|
debug(LOG_ERROR, "resLoadFile: The load function for resource type \"%s\" failed for file \"%s\"", pType, pFile);
|
||||||
psT->release(pData);
|
if (psT->release != NULL)
|
||||||
|
{
|
||||||
|
psT->release(pData);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,7 +500,10 @@ BOOL resLoadFile(const char *pType, const char *pFile)
|
||||||
psRes = resDataInit( GetLastResourceFilename(), HashStringIgnoreCase(GetLastResourceFilename()), pData, resBlockID );
|
psRes = resDataInit( GetLastResourceFilename(), HashStringIgnoreCase(GetLastResourceFilename()), pData, resBlockID );
|
||||||
if (!psRes)
|
if (!psRes)
|
||||||
{
|
{
|
||||||
psT->release(pData);
|
if (psT->release != NULL)
|
||||||
|
{
|
||||||
|
psT->release(pData);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue