Bug 559349 - nsNPAPIPluginInstance::ScheduleTimer leaks newTimer when do_CreateInstance fails, r=jst

--HG--
extra : rebase_source : 7766f8a1a3eadcb2e034741d5624d1347fd1edca
This commit is contained in:
timeless@mozdev.org 2010-04-14 09:03:00 -07:00
parent 0729741b2a
commit 63a9e73cef

View File

@ -1749,8 +1749,10 @@ nsNPAPIPluginInstance::ScheduleTimer(uint32_t interval, NPBool repeat, void (*ti
// create new xpcom timer, scheduled correctly
nsresult rv;
nsCOMPtr<nsITimer> xpcomTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
delete newTimer;
return 0;
}
const short timerType = (repeat ? (short)nsITimer::TYPE_REPEATING_SLACK : (short)nsITimer::TYPE_ONE_SHOT);
xpcomTimer->InitWithFuncCallback(PluginTimerCallback, newTimer, interval, timerType);
newTimer->timer = xpcomTimer;