From 6ad9e38d19aeef21882708deec510fd34516a82b Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Thu, 19 Feb 2009 21:53:52 +0000 Subject: Add a CHECK for NULL observers. I got a NULL pointer exception when notifying on a notification, which is impossible to track down since I don't know who added it. Review URL: http://codereview.chromium.org/20502 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10035 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/notification_service.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'chrome') diff --git a/chrome/common/notification_service.cc b/chrome/common/notification_service.cc index 5b732df..5a9fa72 100644 --- a/chrome/common/notification_service.cc +++ b/chrome/common/notification_service.cc @@ -35,6 +35,13 @@ void NotificationService::AddObserver(NotificationObserver* observer, const NotificationSource& source) { DCHECK(type.value < NotificationType::NOTIFICATION_TYPE_COUNT); + // We have gotten some crashes where the observer pointer is NULL. The problem + // is that this happens when we actually execute a notification, so have no + // way of knowing who the bad observer was. We want to know when this happens + // in release mode so we know what code to blame the crash on (since this is + // guaranteed to crash later). + CHECK(observer); + NotificationObserverList* observer_list; if (HasKey(observers_[type.value], source)) { observer_list = observers_[type.value][source.map_key()]; -- cgit v1.1