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

src: Avoid calling into C++ with a null this #1313

Closed
wants to merge 1 commit into from

Conversation

chearon
Copy link
Contributor

@chearon chearon commented Apr 26, 2023

These tests all crash the process because instance is null when exceptions are off. If ObjectWrap methods try to access anything on this, it's bad news. I don't think the method should get called at all in this case since there's a pending JS exception anyways.

Context: I recently ported node-canvas to node-addon-api and we have tests for this. It was a pain in v8/NAN, and we could remove a lot of code with these changes. I had a positive experience working with node-addon-api, great work everyone!

Copy link
Contributor

@gabrielschulhof gabrielschulhof left a comment

Choose a reason for hiding this comment

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

Looking good. Just a few minor comments.

test/objectwrap.js Outdated Show resolved Hide resolved
test/objectwrap.js Outdated Show resolved Hide resolved
test/objectwrap.js Outdated Show resolved Hide resolved
test/objectwrap.js Outdated Show resolved Hide resolved
napi-inl.h Outdated Show resolved Hide resolved
napi-inl.h Outdated Show resolved Hide resolved
napi-inl.h Outdated Show resolved Hide resolved
@chearon
Copy link
Contributor Author

chearon commented May 2, 2023

Thanks for the review! Think I got everything except for the one I commented on.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

mhdawson pushed a commit that referenced this pull request May 5, 2023
Avoid calling into C++ with a null this when exceptions are off

PR-URL: #1313
Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com
@mhdawson
Copy link
Member

mhdawson commented May 5, 2023

Landed in 858942c

@mhdawson mhdawson closed this May 5, 2023
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
Avoid calling into C++ with a null this when exceptions are off

PR-URL: nodejs/node-addon-api#1313
Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants