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

NPE in finalizer of ProxyObject #894

Closed
fitermay opened this issue Dec 21, 2017 · 3 comments
Closed

NPE in finalizer of ProxyObject #894

fitermay opened this issue Dec 21, 2017 · 3 comments

Comments

@fitermay
Copy link

https://github.com/java-native-access/jna/blob/ea9de70cb73ca0794120666e8ed9794d88ea5c81/contrib/platform/src/com/sun/jna/platform/win32/COM/util/ProxyObject.java line 138

Throws NPE in the finalizer if (Dispatch) this.rawDispatch).getPointer() is null. It tries to call 'equals' on a null reference.

@matthiasblaesing
Copy link
Member

Yes it explodes there - why do you think creating a ProxyObject on a NULL dispatch object is a valid case? How is the code reached? My fix would be to raise the NPE from the constructor and be done with that.

@fitermay
Copy link
Author

It blows up because the object is already disposed. Notice if dispose is called twice it blows up

@matthiasblaesing
Copy link
Member

Ok - on first reading I did not realize, that Pointer.NULL is a fancy way to say null. I added a fix (switch from equals comparison to identity comparison) and added a unittest, that reproduces the problem without the fix.

Thanks for reporting this problem

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

No branches or pull requests

2 participants