summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2017-12-24 01:29:19 (GMT)
committerGitHub <noreply@github.com>2017-12-24 01:29:19 (GMT)
commit4856b0f34a6f4074cd86e66f11a635422374ae98 (patch)
tree2be2f21d4fcc0535f469e17a2a3c005b425bc66a /Modules/_io
parent719ccbca69b21013a783b829de3404b5aa243827 (diff)
downloadcpython-4856b0f34a6f4074cd86e66f11a635422374ae98.zip
cpython-4856b0f34a6f4074cd86e66f11a635422374ae98.tar.gz
cpython-4856b0f34a6f4074cd86e66f11a635422374ae98.tar.bz2
bpo-32402: io: Add missing NULL check. (GH-4971)
_PyUnicode_FromId() may return NULL. Reported by coverity scan: CID 1426868, 1426867.
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/textio.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 6800d2d..d776b5d 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -1037,6 +1037,9 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
if (errors == Py_None) {
errors = _PyUnicode_FromId(&PyId_strict); /* borrowed */
+ if (errors == NULL) {
+ return -1;
+ }
}
else if (!PyUnicode_Check(errors)) {
// Check 'errors' argument here because Argument Clinic doesn't support
@@ -1249,6 +1252,9 @@ textiowrapper_change_encoding(textio *self, PyObject *encoding,
}
else if (errors == Py_None) {
errors = _PyUnicode_FromId(&PyId_strict);
+ if (errors == NULL) {
+ return -1;
+ }
}
const char *c_errors = PyUnicode_AsUTF8(errors);