Skip to content

BUG: Avoid undefined behavior in array.astype()#24030

Merged
seberg merged 2 commits intonumpy:mainfrom
ngoldbaum:ub-fix
Jun 23, 2023
Merged

BUG: Avoid undefined behavior in array.astype()#24030
seberg merged 2 commits intonumpy:mainfrom
ngoldbaum:ub-fix

Conversation

@ngoldbaum
Copy link
Member

If we don't initialize dt_info then the Py_XDECREF in the error path below tries to interpret garbage as a PyObject, leading to undefined behavior.

Fixes one of the issues pointed out in #24023.

@seberg
Copy link
Member

seberg commented Jun 23, 2023

Should we add a test for arr.astype()? But fix is perfect, so also fine without.

@seberg seberg added the 09 - Backport-Candidate PRs tagged should be backported label Jun 23, 2023
@seberg seberg added this to the 1.25.1 release milestone Jun 23, 2023
@seberg seberg merged commit dd231b0 into numpy:main Jun 23, 2023
@seberg
Copy link
Member

seberg commented Jun 23, 2023

Perfect, thanks.

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jun 24, 2023
@charris charris removed this from the 1.25.1 release milestone Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants