-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
BUG: check return value from PyArray_PromoteTypes #12032
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
Conversation
I have no idea why the debug build is segfaulting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't safe. There are two loops here - one of the decrefs no matter how it exits, and the other doesn't. I think the thing to do here is push otmp
into the local scope of each loop.
Fixing |
PyObject *otmp = PySequence_GetItem(op, i); | ||
if (otmp == NULL) { | ||
goto fail; | ||
} | ||
if (!PyArray_CheckAnyScalar(otmp)) { | ||
newtype = PyArray_DescrFromObject(otmp, intype); | ||
Py_XDECREF(intype); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the decref on this line, and then you can omit it below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -2081,14 +2084,15 @@ PyArray_ConvertToCommonType(PyObject *op, int *retn) | |||
newtype = PyArray_DescrFromObject(otmp, stype); | |||
Py_XDECREF(stype); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same again - you're done with the object already by this line, so can decref it immediately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
65d0a85
to
df68e64
Compare
Thanks @mattip! |
Fixes #12031. by checking the return value from
PyArray_PromoteTypes
. Also make sure to decrefotmp
on error.