-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add null pointer protection #5
Comments
That went quickly, I just pressed the button and it closed. Oh well. I don't think there is a reason to reopen right now. In the examples we even check ourselves if for example |
Don't think this is resolved. It's not so much the output, as the input. Eg:
|
But wouldn't adding this kind of security slowdown the code? Is it even needed? |
Null/Invalid pointer dereference is an insidious, and often subtle, programming error. Any check would be quite trivial, a simple |
Ok, that would be easily implemented I guess. I suspect this is needed for every get method and not for every set? |
I was intending to cover the set functions, but thinking about it, all of them need to be covered. I'm not sure if Cython does any inbuilt pointer checking and error handling, but it would be better to instead check ourselves and throw something like For example:
Would become something like:
Because that function is typed ( As for output, what you say is true because we wrap pointers/C++ object with Python objects. Ie:
If It really should be something like this:
That way if the call fails, you get None as expected. |
Couldn't we add a set property for |
It would still return a |
Although some functions should probably raise exceptions on failure.
I would expect these to either succeed, or catastrophically fail with an exception. |
Regarding
Exceptions would probably be a more pythonic solution, but adding nonzero would be quick an easy. |
I agree that it would be quick and easy. If you look at PyOpenGL, they |
Adding that can't hurt. We can then see if the API works as expected. |
Well, to be precise, PyOpenGL's error checking is optional (at the expense of a slightly more complicated import mechanism).
I agree that most GLFW functions are only called very infrequently, so adding error checking should not have a significant impact on performance. It just requires some implementation effort to come up with a consistent error reporting scheme and define the respective exceptions. This adds to the complexity of the wrapper code, which right now is very thin. |
Most functions dont check if a window/monitor/etc pointer is null.
Add checks and throw exceptions.
The text was updated successfully, but these errors were encountered: