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

Conversation

4 participants
@zcbenz
Copy link
Member

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.

@MarshallOfSound
Copy link
Member

left a comment

Nice 👍

@zcbenz zcbenz added the target/5-0-x label Mar 19, 2019

@codebytere

This comment has been minimized.

Copy link
Member

commented Mar 19, 2019

@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 🌱 label Mar 20, 2019

@zcbenz

This comment has been minimized.

Copy link
Member Author

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

2 checks passed

Semantic Pull Request ready to be squashed
Details
release-notes Release notes found

@codebytere codebytere deleted the crash-function-null branch Mar 20, 2019

@release-clerk

This comment has been minimized.

Copy link

commented Mar 20, 2019

Release Notes Persisted

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

@trop

This comment has been minimized.

Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.