-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-142555: Fix null pointer dereference in array.__setitem__ via re-entrant __index__ #142713
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
base: main
Are you sure you want to change the base?
Conversation
Modules/arraymodule.c
Outdated
| return -1; | ||
| else if (x < -128) { | ||
|
|
||
| /* Check buffer validity after PyArg_Parse which may call user-defined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't you always have this issue in all *_setitem formatters? none of them seem to check ob_item
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is also possible that the size was reduced, but ob_item is not NULL. You need to compare the index with the size. This is already checked before calling *_setitem(), but the right place if after calling any user code.
There may also be issues with non-integer formats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the review, I add the check on other *_setitem functions which will invoke a __index__ or __float__ call, and checked size also.
Misc/NEWS.d/next/Core_and_Builtins/2025-12-15-02-02-45.gh-issue-142555.EC9QN_.rst
Outdated
Show resolved
Hide resolved
…e-142555.EC9QN_.rst Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
array:*_setitemfunctions & co may crash on re-entrant__index__#142555