-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[BUG] Missing error checking for overflowing integer casts #2786
Comments
Huh, that's funny. What version of pybind11 are you on? This seems very similar to #2336, but not really. |
I just verified this with 2.6.1, which appears to be current on Pypi. |
Urgh. Let me check, then. Thanks for reporting, already! |
The error seems to be in the implicit conversion from
This should definitely throw an exception if an error occurs. The fix seems reasonably trivial (check for |
Issue description
There appears to be some missing error checking around Python int to C++ long casts that may overflow. In the example below, since the Python -> C++ cast fails, I expect a C++ exception to be thrown. However, it appears the Python interpreter's error state ends up set but pybind11 fails to notice.
I suspect that this method needs to check the interpreter's error state (since
PyLong_AsLong
may fail if the integer is larger than a Clong
)pybind11/include/pybind11/pytypes.h
Line 1143 in 98f1bbb
Reproducible example code
The text was updated successfully, but these errors were encountered: