Fix crash creating a timer when there are no handles available. (bug 5317, r=asherkin)
This commit is contained in:
parent
b9cd424186
commit
97fc093eef
@ -208,6 +208,12 @@ static cell_t smn_CreateTimer(IPluginContext *pCtx, const cell_t *params)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pInfo->UserData = params[3];
|
||||||
|
pInfo->Flags = flags;
|
||||||
|
pInfo->Hook = pFunc;
|
||||||
|
pInfo->Timer = pTimer;
|
||||||
|
pInfo->pContext = pCtx;
|
||||||
|
|
||||||
hndl = handlesys->CreateHandle(g_TimerType, pInfo, pCtx->GetIdentity(), g_pCoreIdent, NULL);
|
hndl = 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
|
/* If we can't get a handle, the timer isn't refcounted against the plugin and
|
||||||
@ -215,25 +221,13 @@ static cell_t smn_CreateTimer(IPluginContext *pCtx, const cell_t *params)
|
|||||||
*/
|
*/
|
||||||
if (hndl == BAD_HANDLE)
|
if (hndl == BAD_HANDLE)
|
||||||
{
|
{
|
||||||
/* Free this for completeness. */
|
pInfo->TimerHandle = BAD_HANDLE;
|
||||||
if (flags & TIMER_DATA_HNDL_CLOSE)
|
|
||||||
{
|
|
||||||
HandleSecurity sec(pCtx->GetIdentity(), g_pCoreIdent);
|
|
||||||
handlesys->FreeHandle(params[3], &sec);
|
|
||||||
}
|
|
||||||
/* Zero everything so there's no conflicts */
|
|
||||||
memset(pInfo, 0, sizeof(TimerInfo));
|
|
||||||
timersys->KillTimer(pTimer);
|
timersys->KillTimer(pTimer);
|
||||||
|
|
||||||
return pCtx->ThrowNativeError("Could not create timer, no more handles");
|
return pCtx->ThrowNativeError("Could not create timer, no more handles");
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->UserData = params[3];
|
|
||||||
pInfo->Flags = flags;
|
|
||||||
pInfo->TimerHandle = hndl;
|
pInfo->TimerHandle = hndl;
|
||||||
pInfo->Hook = pFunc;
|
|
||||||
pInfo->Timer = pTimer;
|
|
||||||
pInfo->pContext = pCtx;
|
|
||||||
|
|
||||||
return hndl;
|
return hndl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user