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

Side by Side Diff: third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp

Issue 2850813004: Add a nullptr check in blink::RequestCallbacks::onSuccess to fix crash. (Closed)
Patch Set: rebase Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "modules/credentialmanager/CredentialsContainer.h" 5 #include "modules/credentialmanager/CredentialsContainer.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include "bindings/core/v8/Dictionary.h" 9 #include "bindings/core/v8/Dictionary.h"
10 #include "bindings/core/v8/ScriptPromise.h" 10 #include "bindings/core/v8/ScriptPromise.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 class RequestCallbacks : public WebCredentialManagerClient::RequestCallbacks { 84 class RequestCallbacks : public WebCredentialManagerClient::RequestCallbacks {
85 WTF_MAKE_NONCOPYABLE(RequestCallbacks); 85 WTF_MAKE_NONCOPYABLE(RequestCallbacks);
86 86
87 public: 87 public:
88 explicit RequestCallbacks(ScriptPromiseResolver* resolver) 88 explicit RequestCallbacks(ScriptPromiseResolver* resolver)
89 : resolver_(resolver) {} 89 : resolver_(resolver) {}
90 ~RequestCallbacks() override {} 90 ~RequestCallbacks() override {}
91 91
92 void OnSuccess(std::unique_ptr<WebCredential> web_credential) override { 92 void OnSuccess(std::unique_ptr<WebCredential> web_credential) override {
93 Frame* frame = 93 ExecutionContext* context =
94 ToDocument(ExecutionContext::From(resolver_->GetScriptState())) 94 ExecutionContext::From(resolver_->GetScriptState());
95 ->GetFrame(); 95 if (!context)
96 return;
97 Frame* frame = ToDocument(context)->GetFrame();
96 SECURITY_CHECK(!frame || frame == frame->Tree().Top()); 98 SECURITY_CHECK(!frame || frame == frame->Tree().Top());
97 99
98 std::unique_ptr<WebCredential> credential = 100 std::unique_ptr<WebCredential> credential =
99 WTF::WrapUnique(web_credential.release()); 101 WTF::WrapUnique(web_credential.release());
100 if (!credential || !frame) { 102 if (!credential || !frame) {
101 resolver_->Resolve(); 103 resolver_->Resolve();
102 return; 104 return;
103 } 105 }
104 106
105 ASSERT(credential->IsPasswordCredential() || 107 ASSERT(credential->IsPasswordCredential() ||
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 ScriptPromise promise = resolver->Promise(); 208 ScriptPromise promise = resolver->Promise();
207 if (!CheckBoilerplate(resolver)) 209 if (!CheckBoilerplate(resolver))
208 return promise; 210 return promise;
209 211
210 CredentialManagerClient::From(ExecutionContext::From(script_state)) 212 CredentialManagerClient::From(ExecutionContext::From(script_state))
211 ->DispatchRequireUserMediation(new NotificationCallbacks(resolver)); 213 ->DispatchRequireUserMediation(new NotificationCallbacks(resolver));
212 return promise; 214 return promise;
213 } 215 }
214 216
215 } // namespace blink 217 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698