From: Serhiy Storchaka Date: Sun, 20 Nov 2016 06:48:07 +0000 (+0200) Subject: Issue #28715: Added error checks for PyUnicode_AsUTF8(). X-Git-Tag: v3.6.0b4~46 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e20973926a2ec19c4b87e460dc6f0edb478ce352;p=thirdparty%2FPython%2Fcpython.git Issue #28715: Added error checks for PyUnicode_AsUTF8(). --- e20973926a2ec19c4b87e460dc6f0edb478ce352 diff --cc Python/ast.c index 33b7df64ec0c,d36a9b78a033..82f4529bf91e --- a/Python/ast.c +++ b/Python/ast.c @@@ -2121,14 -2028,14 +2122,15 @@@ ast_for_atom(struct compiling *c, cons PyObject *type, *value, *tback, *errstr; PyErr_Fetch(&type, &value, &tback); errstr = PyObject_Str(value); - if (errstr) { - char *s = _PyUnicode_AsString(errstr); + if (errstr) + s = PyUnicode_AsUTF8(errstr); + if (s) { PyOS_snprintf(buf, sizeof(buf), "(%s) %s", errtype, s); - Py_DECREF(errstr); } else { + PyErr_Clear(); PyOS_snprintf(buf, sizeof(buf), "(%s) unknown error", errtype); } + Py_XDECREF(errstr); ast_error(c, n, buf); Py_DECREF(type); Py_XDECREF(value);