Python strings ending with '\0' should not be equivalent to their C counterparts in PyUnicode_CompareWithASCIIString

This commit is contained in:
Benjamin Peterson 2010-01-09 21:45:28 +00:00
parent c36c3789de
commit 8667a9b6ea
3 changed files with 26 additions and 0 deletions

View file

@ -7001,6 +7001,11 @@ PyUnicode_CompareWithASCIIString(PyObject* uni, const char* str)
for (i = 0; id[i] && str[i]; i++)
if (id[i] != str[i])
return ((int)id[i] < (int)str[i]) ? -1 : 1;
/* This check keeps Python strings that end in '\0' from comparing equal
to C strings identical up to that point. */
if (PyUnicode_GET_SIZE(uni) != i)
/* We'll say the Python string is longer. */
return 1;
if (id[i])
return 1; /* uni is longer */
if (str[i])