Fixed a bug where natives with no owner could be bound (crashing).

Fixed a bug where FakeNative entries were leaked.

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402422
This commit is contained in:
David Anderson 2008-07-16 03:46:10 +00:00
parent 4d48fc7ae5
commit 9292e0f816

View File

@ -399,7 +399,15 @@ void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin,
/* The native is optional, this is a special case */
if ((native->flags & SP_NTVFLAG_OPTIONAL) == SP_NTVFLAG_OPTIONAL)
{
pEntry->owner->AddWeakRef(WeakNative(pPlugin, index));
/* Only add if there is a valid owner. */
if (pEntry->owner != NULL)
{
pEntry->owner->AddWeakRef(WeakNative(pPlugin, index));
}
else
{
native->status = SP_NATIVE_UNBOUND;
}
}
/* Otherwise, we're a strong dependent and not a weak one */
else
@ -468,6 +476,13 @@ void ShareSystem::ClearNativeFromCache(CNativeOwner *pOwner, const char *name)
return;
}
if (pEntry->fake != NULL)
{
g_pSourcePawn2->DestroyFakeNative(pEntry->func);
delete pEntry->fake;
pEntry->fake = NULL;
}
pEntry->func = NULL;
pEntry->name = NULL;
pEntry->owner = NULL;