diff options
author | Walter Dörwald <walter@livinglogic.de> | 2003-02-09 23:42:56 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2003-02-09 23:42:56 (GMT) |
commit | f6b56aecad067f730d7fc6ae76cca94a26c3c896 (patch) | |
tree | b6d54bbf1d3ed54d8d29141fde610118cb77181e /Objects | |
parent | 95839b8af9418dee446c38825adc302507b42ea3 (diff) | |
download | cpython-f6b56aecad067f730d7fc6ae76cca94a26c3c896.zip cpython-f6b56aecad067f730d7fc6ae76cca94a26c3c896.tar.gz cpython-f6b56aecad067f730d7fc6ae76cca94a26c3c896.tar.bz2 |
Fix two refcounting bugs
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index dfeabf5..6a358da 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3256,6 +3256,7 @@ PyObject *PyUnicode_TranslateCharmap(const Py_UNICODE *p, Py_XDECREF(x); goto onError; } + Py_XDECREF(x); if (x!=Py_None) /* it worked => adjust input pointer */ ++p; else { /* untranslatable character */ @@ -3268,7 +3269,6 @@ PyObject *PyUnicode_TranslateCharmap(const Py_UNICODE *p, const Py_UNICODE *collend = p+1; const Py_UNICODE *coll; - Py_XDECREF(x); /* find all untranslatable characters */ while (collend < endp) { if (charmaptranslate_lookup(*collend, mapping, &x)) @@ -5398,8 +5398,10 @@ unicode_replace(PyUnicodeObject *self, PyObject *args) if (str1 == NULL) return NULL; str2 = (PyUnicodeObject *)PyUnicode_FromObject((PyObject *)str2); - if (str2 == NULL) + if (str2 == NULL) { + Py_DECREF(str1); return NULL; + } result = replace(self, str1, str2, maxcount); |