diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-05-12 17:02:47 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-05-12 17:02:47 (GMT) |
commit | 04b2e69e67f0d7a6283150a0f634b94d9ba148bd (patch) | |
tree | 5a4920959d2d6ec599c6d725e016b74133c6ae5d | |
parent | 424246fbf3953ccdb3b34961db007a453873a3ea (diff) | |
parent | 758153badb991ba3f77c7df913137e274b6eaaf4 (diff) | |
download | cpython-04b2e69e67f0d7a6283150a0f634b94d9ba148bd.zip cpython-04b2e69e67f0d7a6283150a0f634b94d9ba148bd.tar.gz cpython-04b2e69e67f0d7a6283150a0f634b94d9ba148bd.tar.bz2 |
Merge
-rw-r--r-- | Objects/unicodeobject.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 9db87be..4a1cce2 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -9075,12 +9075,15 @@ PyUnicode_Count(PyObject *str, kind1 = PyUnicode_KIND(str_obj); kind2 = PyUnicode_KIND(sub_obj); - kind = kind2; + kind = kind1; buf1 = PyUnicode_DATA(str_obj); buf2 = PyUnicode_DATA(sub_obj); if (kind2 != kind) { - if (kind2 > kind) - return 0; + if (kind2 > kind) { + Py_DECREF(sub_obj); + Py_DECREF(str_obj); + return 0; + } buf2 = _PyUnicode_AsKind(sub_obj, kind); } if (!buf2) @@ -10659,8 +10662,11 @@ PyUnicode_Contains(PyObject *container, PyObject *element) buf1 = PyUnicode_DATA(str); buf2 = PyUnicode_DATA(sub); if (kind2 != kind) { - if (kind2 > kind) + if (kind2 > kind) { + Py_DECREF(sub); + Py_DECREF(str); return 0; + } buf2 = _PyUnicode_AsKind(sub, kind); } if (!buf2) { |