]> granicus.if.org Git - python/commitdiff
Fix unicode_adjust_maxchar(): catch PyUnicode_New() failure
authorVictor Stinner <victor.stinner@gmail.com>
Sat, 16 Jun 2012 01:17:34 +0000 (03:17 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Sat, 16 Jun 2012 01:17:34 +0000 (03:17 +0200)
Objects/unicodeobject.c

index d1f2a35051047f8f6954d671fee289137fbe533a..ad0e2e3843caeede4f1a670fa46155c3dcc48f86 100644 (file)
@@ -2084,7 +2084,8 @@ unicode_adjust_maxchar(PyObject **p_unicode)
             return;
     }
     copy = PyUnicode_New(len, max_char);
-    _PyUnicode_FastCopyCharacters(copy, 0, unicode, 0, len);
+    if (copy != NULL)
+        _PyUnicode_FastCopyCharacters(copy, 0, unicode, 0, len);
     Py_DECREF(unicode);
     *p_unicode = copy;
 }