diff options
author | sabercrombie@chromium.org <sabercrombie@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-08 01:27:56 +0000 |
---|---|---|
committer | sabercrombie@chromium.org <sabercrombie@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-08 01:27:56 +0000 |
commit | 0a950eee38476ec06a79cac9f8deac0ea2aaa8e7 (patch) | |
tree | ae127135a098f923580f7cf3b2915f157b9fe82c /base/message_pump_aurax11.h | |
parent | 1652811069b9da689acc262b9bfe711d18627008 (diff) | |
download | chromium_src-0a950eee38476ec06a79cac9f8deac0ea2aaa8e7.zip chromium_src-0a950eee38476ec06a79cac9f8deac0ea2aaa8e7.tar.gz chromium_src-0a950eee38476ec06a79cac9f8deac0ea2aaa8e7.tar.bz2 |
MessagePumpAuraX11: Make root_window_dispatchers_ an ObserverList.
Using std::vector caused crashes in cases where a Dispatch call resulted in a Dispatcher being added and that addition provoked reallocation of the vector's storage. This resulted in a bad iterator dereference in the dispatch loop.
BUG=chrome-os-partner:15544
TEST=Monitor unplugging/power removal still works. The crash case no longer crashes.
Review URL: https://chromiumcodereview.appspot.com/11593015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175452 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_aurax11.h')
-rw-r--r-- | base/message_pump_aurax11.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/base/message_pump_aurax11.h b/base/message_pump_aurax11.h index 3dbf1a1..486de4f 100644 --- a/base/message_pump_aurax11.h +++ b/base/message_pump_aurax11.h @@ -5,15 +5,15 @@ #ifndef BASE_MESSAGE_PUMP_AURAX11_H #define BASE_MESSAGE_PUMP_AURAX11_H +#include <bitset> +#include <map> + #include "base/memory/scoped_ptr.h" #include "base/message_pump.h" #include "base/message_pump_glib.h" #include "base/message_pump_dispatcher.h" #include "base/message_pump_observer.h" - -#include <bitset> -#include <map> -#include <vector> +#include "base/observer_list.h" // It would be nice to include the X11 headers here so that we use Window // instead of its typedef of unsigned long, but we can't because everything in @@ -77,7 +77,6 @@ class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib, private: typedef std::map<unsigned long, MessagePumpDispatcher*> DispatchersMap; - typedef std::vector<MessagePumpDispatcher*> Dispatchers; // Initializes the glib event source for X. void InitXSource(); @@ -106,7 +105,11 @@ class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib, scoped_ptr<GPollFD> x_poll_; DispatchersMap dispatchers_; - Dispatchers root_window_dispatchers_; + + // Dispatch calls can cause addition of new dispatchers as we iterate + // through them. Use ObserverList to ensure the iterator remains valid across + // additions. + ObserverList<MessagePumpDispatcher> root_window_dispatchers_; unsigned long x_root_window_; |