diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2020-06-19 09:21:42 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2020-06-19 09:21:42 +0200 |
commit | a7a3dafc6fbc018029cf779fa5bfd163f402a3e0 (patch) | |
tree | a4304fae2dbdce8e179a06f8541c3967e65b603d | |
parent | 56262e2971c76c920c61a5e583285834346e15fe (diff) | |
download | cython-a7a3dafc6fbc018029cf779fa5bfd163f402a3e0.tar.gz |
Add safety fix to avoid reading a character from the empty string.
-rw-r--r-- | Cython/Utility/ImportExport.c | 5 |
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 { |