Skip to content
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

BUG: Fix segfault in PyArray_OrderConverter #7481

Merged
merged 1 commit into from
Mar 29, 2016

Conversation

simongibbons
Copy link
Contributor

This fixes a bug in PyArray_OrderConverter where
if a unicode string is passed in which cannot
be converted to ASCII then Py_DECREF would
be called on a null pointer.

Fixes #7475

@@ -535,6 +535,13 @@ PyArray_OrderConverter(PyObject *object, NPY_ORDER *val)
PyObject *tmp;
int ret;
tmp = PyUnicode_AsASCIIString(object);
if(tmp == NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing after if.

@jaimefrio
Copy link
Member

Mostly LGTM, small format nitpick aside. When looking at this I was surprised to find out that a TypeError is being raised if you e.g. pass in order='J', when the sensible thing seems to be a ValueErroras you are doing.

@simongibbons
Copy link
Contributor Author

Cool I've changed that, do you want me to switch to a TypeError to ensure consistency, or change the other case to a ValueError (although that could break some peoples code...)

Or if nothing then I'll just squash the commit to get it ready for merging.

@jaimefrio
Copy link
Member

I think it has to be a ValueError, so lets not break this to conform to some past mistake. Changing the other may be trickier, and would probably require a deprecation cycle, so I wouldn't worry about it in this PR: go ahead and squash your commits and I'll be happy to merge it.

This fixes a bug in PyArray_OrderConverter where
if a unicode string is passed in which cannot
be converted to ASCII then Py_DECREF would
be called on a null pointer.

Fixes numpy#7475
@simongibbons
Copy link
Contributor Author

Squashed.

@jaimefrio jaimefrio merged commit 25d60a9 into numpy:master Mar 29, 2016
@jaimefrio
Copy link
Member

Thanks Simon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: segfault in PyArray_OrderConverter with non-ASCII unicode value
2 participants