Skip to content

Conversation

@aisk
Copy link
Contributor

@aisk aisk commented Dec 14, 2025

return -1;
else if (x < -128) {

/* Check buffer validity after PyArg_Parse which may call user-defined
Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

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.

@aisk aisk marked this pull request as draft December 17, 2025 17:08
@aisk aisk marked this pull request as ready for review December 18, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants