Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 758153b

Browse files
committed
Fix refleaks introduced by 83da67651687.
1 parent e45c0c5 commit 758153b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Objects/unicodeobject.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9079,8 +9079,11 @@ PyUnicode_Count(PyObject *str,
90799079
buf1 = PyUnicode_DATA(str_obj);
90809080
buf2 = PyUnicode_DATA(sub_obj);
90819081
if (kind2 != kind) {
9082-
if (kind2 > kind)
9082+
if (kind2 > kind) {
9083+
Py_DECREF(sub_obj);
9084+
Py_DECREF(str_obj);
90839085
return 0;
9086+
}
90849087
buf2 = _PyUnicode_AsKind(sub_obj, kind);
90859088
}
90869089
if (!buf2)
@@ -10659,8 +10662,11 @@ PyUnicode_Contains(PyObject *container, PyObject *element)
1065910662
buf1 = PyUnicode_DATA(str);
1066010663
buf2 = PyUnicode_DATA(sub);
1066110664
if (kind2 != kind) {
10662-
if (kind2 > kind)
10665+
if (kind2 > kind) {
10666+
Py_DECREF(sub);
10667+
Py_DECREF(str);
1066310668
return 0;
10669+
}
1066410670
buf2 = _PyUnicode_AsKind(sub, kind);
1066510671
}
1066610672
if (!buf2) {

0 commit comments

Comments
 (0)