Fixed crash when a plugin was unloaded before a client convar query had returned results (bug 4044, r=dvander).
This commit is contained in:
parent
07901946d0
commit
fcfd5c7419
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
@ -25,8 +25,6 @@
|
|||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
* this exception to all derivative works. AlliedModders LLC defines further
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
* or <http://www.sourcemod.net/license.php>.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ConVarManager.h"
|
#include "ConVarManager.h"
|
||||||
@ -96,6 +94,8 @@ void ConVarManager::OnSourceModAllInitialized()
|
|||||||
|
|
||||||
SH_ADD_HOOK_STATICFUNC(ICvar, CallGlobalChangeCallbacks, icvar, OnConVarChanged, false);
|
SH_ADD_HOOK_STATICFUNC(ICvar, CallGlobalChangeCallbacks, icvar, OnConVarChanged, false);
|
||||||
|
|
||||||
|
g_PluginSys.AddPluginsListener(this);
|
||||||
|
|
||||||
/* Add the 'convars' option to the 'sm' console command */
|
/* Add the 'convars' option to the 'sm' console command */
|
||||||
g_RootMenu.AddRootConsoleCommand("cvars", "View convars created by a plugin", this);
|
g_RootMenu.AddRootConsoleCommand("cvars", "View convars created by a plugin", this);
|
||||||
}
|
}
|
||||||
@ -162,6 +162,8 @@ void ConVarManager::OnSourceModShutdown()
|
|||||||
/* Remove the 'convars' option from the 'sm' console command */
|
/* Remove the 'convars' option from the 'sm' console command */
|
||||||
g_RootMenu.RemoveRootConsoleCommand("cvars", this);
|
g_RootMenu.RemoveRootConsoleCommand("cvars", this);
|
||||||
|
|
||||||
|
g_PluginSys.RemovePluginsListener(this);
|
||||||
|
|
||||||
/* Remove the 'ConVar' handle type */
|
/* Remove the 'ConVar' handle type */
|
||||||
g_HandleSys.RemoveType(m_ConVarType, g_pCoreIdent);
|
g_HandleSys.RemoveType(m_ConVarType, g_pCoreIdent);
|
||||||
}
|
}
|
||||||
@ -252,12 +254,23 @@ void ConVarManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na
|
|||||||
void ConVarManager::OnPluginUnloaded(IPlugin *plugin)
|
void ConVarManager::OnPluginUnloaded(IPlugin *plugin)
|
||||||
{
|
{
|
||||||
ConVarList *pConVarList;
|
ConVarList *pConVarList;
|
||||||
|
List<ConVarQuery>::iterator iter;
|
||||||
|
|
||||||
/* If plugin has a convar list, free its memory */
|
/* If plugin has a convar list, free its memory */
|
||||||
if (plugin->GetProperty("ConVarList", (void **)&pConVarList, true))
|
if (plugin->GetProperty("ConVarList", (void **)&pConVarList, true))
|
||||||
{
|
{
|
||||||
delete pConVarList;
|
delete pConVarList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove convar queries for this plugin that haven't returned results yet */
|
||||||
|
for (iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end(); iter++)
|
||||||
|
{
|
||||||
|
ConVarQuery &query = (*iter);
|
||||||
|
if (query.pCallback->GetParentRuntime() == plugin->GetRuntime())
|
||||||
|
{
|
||||||
|
m_ConVarQueries.erase(iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConVarManager::OnHandleDestroy(HandleType_t type, void *object)
|
void ConVarManager::OnHandleDestroy(HandleType_t type, void *object)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourcePawn
|
* SourcePawn
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
@ -25,8 +25,6 @@
|
|||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
* this exception to all derivative works. AlliedModders LLC defines further
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
* or <http://www.sourcemod.net/license.php>.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _INCLUDE_SOURCEPAWN_VM_API_H_
|
#ifndef _INCLUDE_SOURCEPAWN_VM_API_H_
|
||||||
@ -61,6 +59,7 @@ typedef struct sp_context_s sp_context_t;
|
|||||||
namespace SourcePawn
|
namespace SourcePawn
|
||||||
{
|
{
|
||||||
class IVirtualMachine;
|
class IVirtualMachine;
|
||||||
|
class IPluginRuntime;
|
||||||
|
|
||||||
/* Parameter flags */
|
/* Parameter flags */
|
||||||
#define SM_PARAM_COPYBACK (1<<0) /**< Copy an array/reference back after call */
|
#define SM_PARAM_COPYBACK (1<<0) /**< Copy an array/reference back after call */
|
||||||
@ -260,6 +259,13 @@ namespace SourcePawn
|
|||||||
const cell_t *params,
|
const cell_t *params,
|
||||||
unsigned int num_params,
|
unsigned int num_params,
|
||||||
cell_t *result) =0;
|
cell_t *result) =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns parent plugin's runtime
|
||||||
|
*
|
||||||
|
* @return IPluginRuntime pointer.
|
||||||
|
*/
|
||||||
|
virtual IPluginRuntime *GetParentRuntime() =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourcePawn
|
* SourcePawn
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
@ -25,8 +25,6 @@
|
|||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
* this exception to all derivative works. AlliedModders LLC defines further
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
* or <http://www.sourcemod.net/license.php>.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -332,6 +330,11 @@ int CFunction::Execute2(IPluginContext *ctx, cell_t *result)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPluginRuntime *CFunction::GetParentRuntime()
|
||||||
|
{
|
||||||
|
return m_pRuntime;
|
||||||
|
}
|
||||||
|
|
||||||
funcid_t CFunction::GetFunctionID()
|
funcid_t CFunction::GetFunctionID()
|
||||||
{
|
{
|
||||||
return m_FnId;
|
return m_FnId;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourcePawn
|
* SourcePawn
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
@ -25,8 +25,6 @@
|
|||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
* this exception to all derivative works. AlliedModders LLC defines further
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
* or <http://www.sourcemod.net/license.php>.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _INCLUDE_SOURCEMOD_BASEFUNCTION_H_
|
#ifndef _INCLUDE_SOURCEMOD_BASEFUNCTION_H_
|
||||||
@ -82,6 +80,7 @@ public:
|
|||||||
const cell_t *params,
|
const cell_t *params,
|
||||||
unsigned int num_params,
|
unsigned int num_params,
|
||||||
cell_t *result);
|
cell_t *result);
|
||||||
|
IPluginRuntime *GetParentRuntime();
|
||||||
public:
|
public:
|
||||||
void Set(BaseRuntime *runtime, funcid_t fnid, uint32_t pub_id);
|
void Set(BaseRuntime *runtime, funcid_t fnid, uint32_t pub_id);
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user