FIX: reject out-of-range charmap index in FT2Font.set_charmap#31859
Conversation
FT2Font.set_charmap(i) only checked the upper bound (i >= num_charmaps). A negative i passed the check and was used to index face->charmaps[i], an out-of-bounds read whose result was then dereferenced by FT_Set_Charmap, crashing the interpreter (e.g. set_charmap(-1)). Reject negative indices as well, raising the same RuntimeError already used for too-large indices. Valid indices in [0, num_charmaps) are unaffected.
|
Thank you for opening your first PR into Matplotlib! If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
|
I used AI tools (Claude and ChatGPT) to help with code navigation, repository research, and understanding the relevant code paths. The investigation, validation, testing, and final code changes were performed and verified manually by me. I understand the change and can answer questions about the implementation and reasoning behind it. |
…859-on-v3.11.x Backport PR #31859 on branch v3.11.x (FIX: reject out-of-range charmap index in FT2Font.set_charmap)
FT2Font.set_charmap(i)validated only the upper bound: