diff --git a/components/omnibox/browser/clipboard_provider.cc b/components/omnibox/browser/clipboard_provider.cc index 3b6c952a88f8e..b4f4990f2e9d2 100644 --- a/components/omnibox/browser/clipboard_provider.cc +++ b/components/omnibox/browser/clipboard_provider.cc @@ -143,6 +143,14 @@ void ClipboardProvider::Start(const AutocompleteInput& input, bool minimal_changes) { using OEP = ::metrics::OmniboxEventProto; + // Drop any in-flight UpdateClipboardMatchWithContent / image-encode callbacks + // before the controller publishes a new result set. Those callbacks bind a + // raw AutocompleteMatch* into AutocompleteController::published_result_, + // whose backing storage is freed by the next NotifyChanged(). + // AutocompleteController::Start() does not call Stop() on providers, so this + // must be invalidated here as well as in Stop(). + callback_weak_ptr_factory_.InvalidateWeakPtrs(); + matches_.clear(); // If the user started typing, do not offer clipboard based match.