From 267275b06b615c79ac298e5d6789996996a70439 Mon Sep 17 00:00:00 2001 From: "timeless@mozdev.org" Date: Wed, 22 Jul 2009 17:31:01 -0500 Subject: [PATCH] Bug 504473 FORWARD_NULL deref of mPresContext in nsEventStateManager::GetEventTarget r=smaug sr=smaug --- content/events/src/nsEventStateManager.cpp | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 9a44607fc8f7..52a995204e7c 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -3719,25 +3719,25 @@ nsEventStateManager::CheckForAndDispatchClick(nsPresContext* aPresContext, NS_IMETHODIMP nsEventStateManager::GetEventTarget(nsIFrame **aFrame) { - if (!mCurrentTarget && mCurrentTargetContent) { - if (mPresContext) { - nsIPresShell *shell = mPresContext->GetPresShell(); - if (shell) { - mCurrentTarget = shell->GetPrimaryFrameFor(mCurrentTargetContent); - } + nsIPresShell *shell; + if (mCurrentTarget || + !mPresContext || + !(shell = mPresContext->GetPresShell())) { + *aFrame = mCurrentTarget; + return NS_OK; + } + + if (mCurrentTargetContent) { + mCurrentTarget = shell->GetPrimaryFrameFor(mCurrentTargetContent); + if (mCurrentTarget) { + *aFrame = mCurrentTarget; + return NS_OK; } } - if (!mCurrentTarget) { - nsIPresShell *presShell = mPresContext->GetPresShell(); - if (presShell) { - nsIFrame* frame = nsnull; - presShell->GetEventTargetFrame(&frame); - mCurrentTarget = frame; - } - } - - *aFrame = mCurrentTarget; + nsIFrame* frame = nsnull; + shell->GetEventTargetFrame(&frame); + *aFrame = mCurrentTarget = frame; return NS_OK; }