diff Python/compile.c @ 72493:c4dcb68e0711

Check for PyUnicode_CopyCharacters() failure
author Victor Stinner <victor.stinner@haypocalc.com>
date Wed, 28 Sep 2011 21:39:17 +0200
parents 8beaa9a37387
children e1dbc72bd97f
line wrap: on
line diff
--- a/Python/compile.c	Wed Sep 28 21:37:03 2011 +0200
+++ b/Python/compile.c	Wed Sep 28 21:39:17 2011 +0200
@@ -245,8 +245,14 @@
         return 0;
     /* ident = "_" + priv[ipriv:] + ident # i.e. 1+plen+nlen bytes */
     PyUnicode_WRITE(PyUnicode_KIND(result), PyUnicode_DATA(result), 0, '_');
-    PyUnicode_CopyCharacters(result, 1, privateobj, ipriv, plen);
-    PyUnicode_CopyCharacters(result, plen+1, ident, 0, nlen);
+    if (PyUnicode_CopyCharacters(result, 1, privateobj, ipriv, plen) < 0) {
+        Py_DECREF(result);
+        return NULL;
+    }
+    if (PyUnicode_CopyCharacters(result, plen+1, ident, 0, nlen) < 0) {
+        Py_DECREF(result);
+        return NULL;
+    }
     return result;
 }