Commit 9f18281a authored by Ronan Lamy's avatar Ronan Lamy

Fix segfault on PyPy3 when passing NULL method_name to _Pyx_dict_iterator

parent d2653b4d
...@@ -294,18 +294,20 @@ static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_di ...@@ -294,18 +294,20 @@ static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_di
// On PyPy3, we need to translate manually a few method names. // On PyPy3, we need to translate manually a few method names.
// This logic is not needed on CPython thanks to the fast case above. // This logic is not needed on CPython thanks to the fast case above.
static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL; static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
const char *name = PyUnicode_AsUTF8(method_name);
PyObject **pp = NULL; PyObject **pp = NULL;
if (strcmp(name, "iteritems") == 0) pp = &py_items; if (method_name) {
else if (strcmp(name, "iterkeys") == 0) pp = &py_keys; const char *name = PyUnicode_AsUTF8(method_name);
else if (strcmp(name, "itervalues") == 0) pp = &py_values; if (strcmp(name, "iteritems") == 0) pp = &py_items;
if (pp) { else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
if (!*pp) { else if (strcmp(name, "itervalues") == 0) pp = &py_values;
*pp = PyUnicode_FromString(name + 4); if (pp) {
if (!*pp) if (!*pp) {
return NULL; *pp = PyUnicode_FromString(name + 4);
if (!*pp)
return NULL;
}
method_name = *pp;
} }
method_name = *pp;
} }
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment