diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-28 19:39:17 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-28 19:39:17 (GMT) |
commit | 6c7a52a46f862eee841bf705653cefa57b53efbc (patch) | |
tree | 4dacd0e16c656b65ee461b7b67a935c7e904d919 /Python/compile.c | |
parent | be78eaf2de68acce390877b43fa829ef59b493f1 (diff) | |
download | cpython-6c7a52a46f862eee841bf705653cefa57b53efbc.zip cpython-6c7a52a46f862eee841bf705653cefa57b53efbc.tar.gz cpython-6c7a52a46f862eee841bf705653cefa57b53efbc.tar.bz2 |
Check for PyUnicode_CopyCharacters() failure
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c index 5f03792..9067722 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -245,8 +245,14 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident) 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; } |