Skip to content

BUG,MAINT: Fix utf-8 character stripping memory access#26962

Merged
charris merged 2 commits into
numpy:maintenance/2.0.xfrom
charris:backport-26919
Jul 17, 2024
Merged

BUG,MAINT: Fix utf-8 character stripping memory access#26962
charris merged 2 commits into
numpy:maintenance/2.0.xfrom
charris:backport-26919

Conversation

@charris
Copy link
Copy Markdown
Member

@charris charris commented Jul 17, 2024

Backport of #26919.

This fixes the memory access bug, the old if was there for a reason (obviously...), but unfortunately only the sanitizer checks noticed that.

But to make it clear, I had to just also rename/change things a bit making it unsigned and using a stop range rather than the actual range is just much clearer here where the range can go to length 0 IMO.

I.e. the old code had to check for j >= 0 not j > 0 (j being the last character index), because j could go negative.

Fixes the sanitizer tests.

@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Jul 17, 2024
@charris charris added this to the 2.0.1 release milestone Jul 17, 2024
seberg added 2 commits July 16, 2024 19:53
This fixes the memory access bug, the old if was there for a reason
(obviously...), but unfortunately only the sanitizer checks noticed
that.

But to make it clear, I had to just also rename/change things a bit
making it unsigned and using a stop range rather than the actual
range is just much clearer here where the range can go to length 0
IMO.

I.e. the old code had to check for `j >= 0` not `j > 0` (j being the
last character index), because `j` could go negative.

Fixes the sanitizer tests.
@charris charris merged commit 89630c0 into numpy:maintenance/2.0.x Jul 17, 2024
@charris charris deleted the backport-26919 branch July 17, 2024 02:49
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.

2 participants