diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-01-09 21:45:28 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-01-09 21:45:28 (GMT) |
commit | 8667a9b6ea414fb78c0c71d411d86c5cfffbf549 (patch) | |
tree | de4e301e504d9b734a543f441581e99ee307537e /Objects | |
parent | c36c3789dee99b3e2d01ee47731b62200157ba16 (diff) | |
download | cpython-8667a9b6ea414fb78c0c71d411d86c5cfffbf549.zip cpython-8667a9b6ea414fb78c0c71d411d86c5cfffbf549.tar.gz cpython-8667a9b6ea414fb78c0c71d411d86c5cfffbf549.tar.bz2 |
Python strings ending with '\0' should not be equivalent to their C counterparts in PyUnicode_CompareWithASCIIString
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 9c0be9b..40377ea 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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]) |