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

Side by Side Diff: src/inspector/v8-console.cc

Issue 2388463002: [inspector] fix use-after-free in ConsoleHelper::reportCall (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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project 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 "src/inspector/v8-console.h" 5 #include "src/inspector/v8-console.h"
6 6
7 #include "src/base/macros.h" 7 #include "src/base/macros.h"
8 #include "src/inspector/injected-script.h" 8 #include "src/inspector/injected-script.h"
9 #include "src/inspector/inspected-context.h" 9 #include "src/inspector/inspected-context.h"
10 #include "src/inspector/string-util.h" 10 #include "src/inspector/string-util.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 void reportCallWithArgument(ConsoleAPIType type, const String16& message) { 86 void reportCallWithArgument(ConsoleAPIType type, const String16& message) {
87 std::vector<v8::Local<v8::Value>> arguments(1, 87 std::vector<v8::Local<v8::Value>> arguments(1,
88 toV8String(m_isolate, message)); 88 toV8String(m_isolate, message));
89 reportCall(type, arguments); 89 reportCall(type, arguments);
90 } 90 }
91 91
92 void reportCall(ConsoleAPIType type, 92 void reportCall(ConsoleAPIType type,
93 const std::vector<v8::Local<v8::Value>>& arguments) { 93 const std::vector<v8::Local<v8::Value>>& arguments) {
94 InspectedContext* inspectedContext = ensureInspectedContext(); 94 InspectedContext* inspectedContext = ensureInspectedContext();
95 if (!inspectedContext) return; 95 if (!inspectedContext) return;
96 int contextGroupId = inspectedContext->contextGroupId();
96 V8InspectorImpl* inspector = inspectedContext->inspector(); 97 V8InspectorImpl* inspector = inspectedContext->inspector();
97 std::unique_ptr<V8ConsoleMessage> message = 98 std::unique_ptr<V8ConsoleMessage> message =
98 V8ConsoleMessage::createForConsoleAPI( 99 V8ConsoleMessage::createForConsoleAPI(
99 inspector->client()->currentTimeMS(), type, arguments, 100 inspector->client()->currentTimeMS(), type, arguments,
100 inspector->debugger()->captureStackTrace(false), inspectedContext); 101 inspector->debugger()->captureStackTrace(false), inspectedContext);
101 inspector->ensureConsoleMessageStorage(inspectedContext->contextGroupId()) 102 inspector->ensureConsoleMessageStorage(contextGroupId)
102 ->addMessage(std::move(message)); 103 ->addMessage(std::move(message));
103 } 104 }
104 105
105 void reportDeprecatedCall(const char* id, const String16& message) { 106 void reportDeprecatedCall(const char* id, const String16& message) {
106 if (checkAndSetPrivateFlagOnConsole(id, false)) return; 107 if (checkAndSetPrivateFlagOnConsole(id, false)) return;
107 std::vector<v8::Local<v8::Value>> arguments(1, 108 std::vector<v8::Local<v8::Value>> arguments(1,
108 toV8String(m_isolate, message)); 109 toV8String(m_isolate, message));
109 reportCall(ConsoleAPIType::kWarning, arguments); 110 reportCall(ConsoleAPIType::kWarning, arguments);
110 } 111 }
111 112
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 ->GetOwnPropertyDescriptor( 910 ->GetOwnPropertyDescriptor(
910 m_context, v8::Local<v8::String>::Cast(name)) 911 m_context, v8::Local<v8::String>::Cast(name))
911 .ToLocal(&descriptor); 912 .ToLocal(&descriptor);
912 DCHECK(success); 913 DCHECK(success);
913 USE(success); 914 USE(success);
914 } 915 }
915 } 916 }
916 } 917 }
917 918
918 } // namespace v8_inspector 919 } // namespace v8_inspector
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