summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-06-19 09:21:42 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-06-19 09:21:42 +0200
commita7a3dafc6fbc018029cf779fa5bfd163f402a3e0 (patch)
treea4304fae2dbdce8e179a06f8541c3967e65b603d
parent56262e2971c76c920c61a5e583285834346e15fe (diff)
downloadcython-a7a3dafc6fbc018029cf779fa5bfd163f402a3e0.tar.gz
Add safety fix to avoid reading a character from the empty string.
-rw-r--r--Cython/Utility/ImportExport.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Cython/Utility/ImportExport.c b/Cython/Utility/ImportExport.c
index acb26d36b..e3c0cafaf 100644
--- a/Cython/Utility/ImportExport.c
+++ b/Cython/Utility/ImportExport.c
@@ -152,10 +152,11 @@ __Pyx_import_all_from(PyObject *locals, PyObject *v)
}
if (skip_leading_underscores &&
#if PY_MAJOR_VERSION < 3
- PyString_Check(name) &&
+ likely(PyString_Check(name)) &&
PyString_AS_STRING(name)[0] == '_')
#else
- PyUnicode_Check(name) &&
+ likely(PyUnicode_Check(name)) &&
+ likely(__Pyx_PyUnicode_GET_LENGTH(name)) &&
__Pyx_PyUnicode_READ_CHAR(name, 0) == '_')
#endif
{