diff --git a/dom/events/nsEventListenerManager.cpp b/dom/events/nsEventListenerManager.cpp index fc367734646..1c0d4435070 100644 --- a/dom/events/nsEventListenerManager.cpp +++ b/dom/events/nsEventListenerManager.cpp @@ -809,8 +809,7 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS JS::Rooted scope(cx, listener->GetEventScope()); - nsCOMPtr typeAtom = aListenerStruct->mTypeAtom; - nsIAtom* attrName = typeAtom; + nsIAtom* attrName = aListenerStruct->mTypeAtom; if (aListenerStruct->mHandlerIsString) { // OK, we didn't find an existing compiled event handler. Flag us @@ -851,7 +850,6 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS body = &handlerBody; aElement = element; } - aListenerStruct = nullptr; uint32_t lineNo = 0; nsAutoCString url (NS_LITERAL_CSTRING("-moz-evil:lying-event-listener")); @@ -866,7 +864,7 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS uint32_t argCount; const char **argNames; nsContentUtils::GetEventArgNames(aElement->GetNameSpaceID(), - typeAtom, + aListenerStruct->mTypeAtom, &argCount, &argNames); JSAutoCompartment ac(cx, context->GetWindowProxy()); @@ -896,13 +894,11 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS JS::Rooted handlerFun(cx); result = nsJSUtils::CompileFunction(cx, JS::NullPtr(), options, - nsAtomCString(typeAtom), + nsAtomCString(aListenerStruct->mTypeAtom), argCount, argNames, *body, handlerFun.address()); NS_ENSURE_SUCCESS(result, result); handler = handlerFun; NS_ENSURE_TRUE(handler, NS_ERROR_FAILURE); - } else { - aListenerStruct = nullptr; } if (handler) { @@ -910,6 +906,7 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS // Bind it JS::Rooted boundHandler(cx); context->BindCompiledEventHandler(mTarget, scope, handler, &boundHandler); + aListenerStruct = nullptr; // Note - We pass null for aIncumbentGlobal below. We could also pass the // compilation global, but since the handler is guaranteed to be scripted, // there's no need to use an override, since the JS engine will always give