Fixed possible crash when reloading a plugin with an invalid binary (bug 5288, r=psychonic).

This commit is contained in:
Asher Baker 2012-05-27 01:51:03 +01:00
parent c15a91dbcc
commit 6121c098c8

View File

@ -1004,12 +1004,15 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool de
pPlugin->m_pRuntime = g_pSourcePawn2->LoadPlugin(co, fullpath, &err); pPlugin->m_pRuntime = g_pSourcePawn2->LoadPlugin(co, fullpath, &err);
if (pPlugin->m_pRuntime == NULL) if (pPlugin->m_pRuntime == NULL)
{
if (error)
{ {
UTIL_Format(error, UTIL_Format(error,
maxlength, maxlength,
"Unable to load plugin (error %d: %s)", "Unable to load plugin (error %d: %s)",
err, err,
g_pSourcePawn2->GetErrorString(err)); g_pSourcePawn2->GetErrorString(err));
}
pPlugin->m_status = Plugin_BadLoad; pPlugin->m_status = Plugin_BadLoad;
} }
else else
@ -1019,11 +1022,14 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool de
pPlugin->m_status = Plugin_Created; pPlugin->m_status = Plugin_Created;
} }
else else
{
if (error)
{ {
UTIL_Format(error, maxlength, "%s", pPlugin->m_errormsg); UTIL_Format(error, maxlength, "%s", pPlugin->m_errormsg);
} }
} }
} }
}
LoadRes loadFailure = LoadRes_Failure; LoadRes loadFailure = LoadRes_Failure;
/* Get the status */ /* Get the status */