mirror of
https://github.com/python/cpython.git
synced 2024-12-02 14:24:12 +08:00
Fix two refcounting bugs
This commit is contained in:
parent
95839b8af9
commit
f6b56aecad
@ -3256,6 +3256,7 @@ PyObject *PyUnicode_TranslateCharmap(const Py_UNICODE *p,
|
|||||||
Py_XDECREF(x);
|
Py_XDECREF(x);
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
|
Py_XDECREF(x);
|
||||||
if (x!=Py_None) /* it worked => adjust input pointer */
|
if (x!=Py_None) /* it worked => adjust input pointer */
|
||||||
++p;
|
++p;
|
||||||
else { /* untranslatable character */
|
else { /* untranslatable character */
|
||||||
@ -3268,7 +3269,6 @@ PyObject *PyUnicode_TranslateCharmap(const Py_UNICODE *p,
|
|||||||
const Py_UNICODE *collend = p+1;
|
const Py_UNICODE *collend = p+1;
|
||||||
const Py_UNICODE *coll;
|
const Py_UNICODE *coll;
|
||||||
|
|
||||||
Py_XDECREF(x);
|
|
||||||
/* find all untranslatable characters */
|
/* find all untranslatable characters */
|
||||||
while (collend < endp) {
|
while (collend < endp) {
|
||||||
if (charmaptranslate_lookup(*collend, mapping, &x))
|
if (charmaptranslate_lookup(*collend, mapping, &x))
|
||||||
@ -5398,8 +5398,10 @@ unicode_replace(PyUnicodeObject *self, PyObject *args)
|
|||||||
if (str1 == NULL)
|
if (str1 == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
str2 = (PyUnicodeObject *)PyUnicode_FromObject((PyObject *)str2);
|
str2 = (PyUnicodeObject *)PyUnicode_FromObject((PyObject *)str2);
|
||||||
if (str2 == NULL)
|
if (str2 == NULL) {
|
||||||
|
Py_DECREF(str1);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
result = replace(self, str1, str2, maxcount);
|
result = replace(self, str1, str2, maxcount);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user