diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-18 01:41:18 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-18 01:41:18 +0000 |
commit | 64d1bb4100ed91cadb415a7404d24a3e2e2c7a1e (patch) | |
tree | 2bb3dad5f6b976e9ed1e5ad92c9dd1f401aae1ed | |
parent | 58ed0a25b58f5a333073014c8375fcad626819fa (diff) | |
download | chromium_src-64d1bb4100ed91cadb415a7404d24a3e2e2c7a1e.zip chromium_src-64d1bb4100ed91cadb415a7404d24a3e2e2c7a1e.tar.gz chromium_src-64d1bb4100ed91cadb415a7404d24a3e2e2c7a1e.tar.bz2 |
Don't pass out pointers that belong to other processes.
Review URL: http://codereview.chromium.org/20385
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9931 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/views/focus_manager.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/chrome/views/focus_manager.cc b/chrome/views/focus_manager.cc index 27e396a..923d3d1 100644 --- a/chrome/views/focus_manager.cc +++ b/chrome/views/focus_manager.cc @@ -250,13 +250,19 @@ void FocusManager::UninstallFocusSubclass(HWND window) { // static FocusManager* FocusManager::GetFocusManager(HWND window) { DCHECK(window); - FocusManager* focus_manager = - reinterpret_cast<FocusManager*>(GetProp(window, kFocusManagerKey)); - HWND parent = GetParent(window); - while (!focus_manager && parent) { - focus_manager = - reinterpret_cast<FocusManager*>(GetProp(parent, kFocusManagerKey)); - parent = GetParent(parent); + + // In case parent windows belong to a different process, yet + // have the kFocusManagerKey property set, we have to be careful + // to also check the process id of the window we're checking. + DWORD window_pid = 0, current_pid = GetCurrentProcessId(); + FocusManager* focus_manager; + for (focus_manager = NULL; focus_manager == NULL && IsWindow(window); + window = GetParent(window)) { + GetWindowThreadProcessId(window, &window_pid); + if (current_pid != window_pid) + break; + focus_manager = reinterpret_cast<FocusManager*>( + GetProp(window, kFocusManagerKey)); } return focus_manager; } |