This commit is contained in:
David Anderson 2008-10-31 08:28:24 -05:00
commit be1d12f94f

View File

@ -160,16 +160,19 @@ void TimerNatives::OnTimerEnd(ITimer *pTimer, void *pData)
} }
} }
if ((herr=g_HandleSys.FreeHandle(pInfo->TimerHandle, &sec)) != HandleError_None) if (pInfo->TimerHandle != BAD_HANDLE)
{ {
g_DbgReporter.GenerateError(pInfo->pContext, if ((herr=g_HandleSys.FreeHandle(pInfo->TimerHandle, &sec)) != HandleError_None)
pInfo->Hook->GetFunctionID(), {
SP_ERROR_NATIVE, g_DbgReporter.GenerateError(pInfo->pContext,
"Invalid timer handle %x (error %d) during timer end, displayed function is timer callback, not the stack trace", pInfo->Hook->GetFunctionID(),
pInfo->TimerHandle, SP_ERROR_NATIVE,
herr); "Invalid timer handle %x (error %d) during timer end, displayed function is timer callback, not the stack trace",
return; pInfo->TimerHandle,
herr);
}
} }
DeleteTimerInfo(pInfo); DeleteTimerInfo(pInfo);
} }
@ -206,6 +209,24 @@ static cell_t smn_CreateTimer(IPluginContext *pCtx, const cell_t *params)
hndl = g_HandleSys.CreateHandle(g_TimerType, pInfo, pCtx->GetIdentity(), g_pCoreIdent, NULL); hndl = g_HandleSys.CreateHandle(g_TimerType, pInfo, pCtx->GetIdentity(), g_pCoreIdent, NULL);
/* If we can't get a handle, the timer isn't refcounted against the plugin and
* we need to bail out to prevent a crash.
*/
if (hndl == BAD_HANDLE)
{
/* Free this for completeness. */
if (flags & TIMER_HNDL_CLOSE)
{
HandleSecurity sec(pCtx->GetIdentity(), g_pCoreIdent);
g_HandleSys.FreeHandle(params[3], &sec);
}
/* Zero everything so there's no conflicts */
memset(pInfo, 0, sizeof(TimerInfo));
g_Timers.KillTimer(pTimer);
return pCtx->ThrowNativeError("Could not create timer, no more handles");
}
pInfo->UserData = params[3]; pInfo->UserData = params[3];
pInfo->Flags = flags; pInfo->Flags = flags;
pInfo->TimerHandle = hndl; pInfo->TimerHandle = hndl;