Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: ui/snapshot/snapshot_aura.cc

Issue 2435033002: Fix NULL pointer dereference in FinishedAsyncCopyRequest() (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/snapshot/snapshot.h" 5 #include "ui/snapshot/snapshot.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 static void FinishedAsyncCopyRequest( 46 static void FinishedAsyncCopyRequest(
47 std::unique_ptr<aura::WindowTracker> tracker, 47 std::unique_ptr<aura::WindowTracker> tracker,
48 const gfx::Rect& source_rect, 48 const gfx::Rect& source_rect,
49 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback, 49 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback,
50 int retry_count, 50 int retry_count,
51 std::unique_ptr<cc::CopyOutputResult> result) { 51 std::unique_ptr<cc::CopyOutputResult> result) {
52 static const int kMaxRetries = 5; 52 static const int kMaxRetries = 5;
53 // Retry the copy request if the previous one failed for some reason. 53 // Retry the copy request if the previous one failed for some reason.
54 if (!tracker->windows().empty() && (retry_count < kMaxRetries) && 54 if (!tracker->windows().empty() && (retry_count < kMaxRetries) &&
55 result->IsEmpty()) { 55 result->IsEmpty()) {
56 // Look up window before calling MakeAsyncRequest. Otherwise, due
57 // to undefined (favorably right to left) argument evaluation
58 // order, the tracker might have been passed and set to NULL
59 // before the window is looked up which results in a NULL pointer
60 // dereference.
61 gfx::NativeWindow window = tracker->windows()[0];
56 MakeAsyncCopyRequest( 62 MakeAsyncCopyRequest(
57 tracker->windows()[0], source_rect, 63 window, source_rect,
58 base::Bind(&FinishedAsyncCopyRequest, base::Passed(&tracker), 64 base::Bind(&FinishedAsyncCopyRequest, base::Passed(&tracker),
59 source_rect, callback, retry_count + 1)); 65 source_rect, callback, retry_count + 1));
60 return; 66 return;
61 } 67 }
62 68
63 callback.Run(std::move(result)); 69 callback.Run(std::move(result));
64 } 70 }
65 71
66 static void MakeInitialAsyncCopyRequest( 72 static void MakeInitialAsyncCopyRequest(
67 gfx::NativeWindow window, 73 gfx::NativeWindow window,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 void GrabViewSnapshotAsync( 106 void GrabViewSnapshotAsync(
101 gfx::NativeView view, 107 gfx::NativeView view,
102 const gfx::Rect& source_rect, 108 const gfx::Rect& source_rect,
103 scoped_refptr<base::TaskRunner> background_task_runner, 109 scoped_refptr<base::TaskRunner> background_task_runner,
104 const GrabWindowSnapshotAsyncPNGCallback& callback) { 110 const GrabWindowSnapshotAsyncPNGCallback& callback) {
105 GrabWindowSnapshotAsync(view, source_rect, background_task_runner, callback); 111 GrabWindowSnapshotAsync(view, source_rect, background_task_runner, callback);
106 } 112 }
107 113
108 114
109 } // namespace ui 115 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698