Skip to content

BUG: fix fencepost error in StringDType internals #29284

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

Merged
merged 1 commit into from
Jun 27, 2025

Conversation

charris
Copy link
Member

@charris charris commented Jun 27, 2025

Backport of #29269.

Fixes #29261

This makes all the comparisons with NPY_MEDIUM_STRING_MAX_SIZE use <= consistently:

$ rg NPY_MEDIUM_STRING_MAX_SIZE
numpy/_core/src/multiarray/stringdtype/static_string.c
96:#define NPY_MEDIUM_STRING_MAX_SIZE 0xFF  // 255
165:    if (size <= NPY_MEDIUM_STRING_MAX_SIZE) {
199:    if (size <= NPY_MEDIUM_STRING_MAX_SIZE) {
481:            if (size <= NPY_MEDIUM_STRING_MAX_SIZE) {

This makes all the comparisons with NPY_MEDIUM_STRING_MAX_SIZE use <= consistently:
@charris charris added this to the 2.3.2 release milestone Jun 27, 2025
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Jun 27, 2025
@charris charris changed the base branch from main to maintenance/2.3.x June 27, 2025 14:37
@charris charris changed the title Backport 29269 BUG: fix fencepost error in StringDType internals Jun 27, 2025
@charris charris closed this Jun 27, 2025
@charris charris reopened this Jun 27, 2025
@charris charris merged commit 9ebfca5 into numpy:maintenance/2.3.x Jun 27, 2025
75 checks passed
@charris charris deleted the backport-29269 branch June 27, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 08 - Backport Used to tag backport PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: StringDType mis-handles 255-character ASCII strings during contiguous slice assignment
2 participants