Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check the result when calling js function #17443

Merged
merged 2 commits into from Mar 20, 2019
Merged

Conversation

zcbenz
Copy link
Member

@zcbenz zcbenz commented Mar 19, 2019

Description of Change

When a JS function returns undefined, the returned v8::MaybeLocal in C++ would be empty, and calling ToLocalChecked() without checking would crash immediately.

This PR does 2 things:

  1. Check whether MaybeLocal is empty before using it;
  2. Replace ToLocalChecked with IsEmpty where the only purpose is to suppress compiler warning.

Checklist

Release Notes

Notes: Fix crash when passing callbacks which return undefined to some APIs.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Mar 19, 2019
Copy link
Member

@MarshallOfSound MarshallOfSound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@codebytere
Copy link
Member

@zcbenz this potentially has broken:

webContents module getAllWebContents() API returns an array of web contents - returns an array of web contents

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Mar 20, 2019
@zcbenz
Copy link
Member Author

zcbenz commented Mar 20, 2019

@zcbenz this potentially has broken:

It seems to be a flaky one, the CI is green after restarting.

@codebytere codebytere merged commit 671533f into master Mar 20, 2019
@codebytere codebytere deleted the crash-function-null branch March 20, 2019 15:27
@release-clerk
Copy link

release-clerk bot commented Mar 20, 2019

Release Notes Persisted

Fix crash when passing callbacks which return undefined to some APIs.

@trop
Copy link
Contributor

trop bot commented Mar 20, 2019

I have automatically backported this PR to "5-0-x", please check out #17481

@sofianguy sofianguy added this to Fixed in 5.0.0-beta.7 in 5.0.x Mar 28, 2019
kiku-jw pushed a commit to kiku-jw/electron that referenced this pull request May 16, 2019
* fix: check the result when calling js function

* test: should not crash when callback returns nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
5.0.x
Fixed in 5.0.0-beta.7
Development

Successfully merging this pull request may close these issues.

None yet

4 participants