Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd80195

Browse filesBrowse files
addaleaxMylesBorins
authored andcommitted
src: make MakeCallback() check can_call_into_js before getting method
There is a check for this in the inner `MakeCallback()` function called by it, but since the `Get()` call here can also result in a call into JS, we should ideally check the flag before that. PR-URL: #35424 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent edf3fbb commit cd80195
Copy full SHA for cd80195

File tree

Expand file treeCollapse file tree

1 file changed

+13
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-4
lines changed
Open diff view settings
Collapse file

‎src/api/callback.cc‎

Copy file name to clipboardExpand all lines: src/api/callback.cc
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,19 @@ MaybeLocal<Value> MakeCallback(Isolate* isolate,
225225
int argc,
226226
Local<Value> argv[],
227227
async_context asyncContext) {
228-
Local<Value> callback_v =
229-
recv->Get(isolate->GetCurrentContext(), symbol).ToLocalChecked();
230-
if (callback_v.IsEmpty()) return Local<Value>();
231-
if (!callback_v->IsFunction()) return Local<Value>();
228+
// Check can_call_into_js() first because calling Get() might do so.
229+
Environment* env = Environment::GetCurrent(recv->CreationContext());
230+
CHECK_NOT_NULL(env);
231+
if (!env->can_call_into_js()) return Local<Value>();
232+
233+
Local<Value> callback_v;
234+
if (!recv->Get(isolate->GetCurrentContext(), symbol).ToLocal(&callback_v))
235+
return Local<Value>();
236+
if (!callback_v->IsFunction()) {
237+
// This used to return an empty value, but Undefined() makes more sense
238+
// since no exception is pending here.
239+
return Undefined(isolate);
240+
}
232241
Local<Function> callback = callback_v.As<Function>();
233242
return MakeCallback(isolate, recv, callback, argc, argv, asyncContext);
234243
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.