Index: extensions/renderer/event_bindings.cc |
diff --git a/extensions/renderer/event_bindings.cc b/extensions/renderer/event_bindings.cc |
index de99257c3824e78046708ef98c51fe8fc8ca15ed..db5fb60f428af90a3ce4ba3edcfee6a77b1a6729 100644 |
--- a/extensions/renderer/event_bindings.cc |
+++ b/extensions/renderer/event_bindings.cc |
@@ -272,14 +272,18 @@ void EventBindings::AttachFilteredEvent( |
filter = base::DictionaryValue::From(std::move(filter_value)); |
} |
- // Hold onto a weak reference to |filter| so that it can be used after passing |
- // ownership to |event_filter|. |
- base::DictionaryValue* filter_weak = filter.get(); |
int id = g_event_filter.Get().AddEventMatcher( |
event_name, ParseEventMatcher(std::move(filter))); |
+ if (id == -1) { |
+ args.GetReturnValue().Set(static_cast<int32_t>(-1)); |
+ return; |
+ } |
attached_matcher_ids_.insert(id); |
// Only send IPCs the first time a filter gets added. |
+ const EventMatcher* matcher = g_event_filter.Get().GetEventMatcher(id); |
+ DCHECK(matcher); |
+ base::DictionaryValue* filter_weak = matcher->value(); |
std::string extension_id = context()->GetExtensionID(); |
if (AddFilter(event_name, extension_id, *filter_weak)) { |
bool lazy = ExtensionFrameHelper::IsContextForEventPage(context()); |