]> granicus.if.org Git - python/commitdiff
Fix two refcounting bugs
authorWalter Dörwald <walter@livinglogic.de>
Sun, 9 Feb 2003 23:42:56 +0000 (23:42 +0000)
committerWalter Dörwald <walter@livinglogic.de>
Sun, 9 Feb 2003 23:42:56 +0000 (23:42 +0000)
Objects/unicodeobject.c

index dfeabf5e9a9e177ddda25ec90f63a2088012bb0c..6a358da6f1e04d5e45a44a88bebd781327cd01a4 100644 (file)
@@ -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);