summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2018-12-07 10:11:30 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-12-07 10:11:30 (GMT)
commit4c49da0cb7434c676d70b9ccf38aca82ac0d64a9 (patch)
treeaae3660f9a5bc462830107cf2311b2557898e268 /Modules/_io
parent3a521f0b6167628f975c773b56c7daf8d33d6f40 (diff)
downloadcpython-4c49da0cb7434c676d70b9ccf38aca82ac0d64a9.zip
cpython-4c49da0cb7434c676d70b9ccf38aca82ac0d64a9.tar.gz
cpython-4c49da0cb7434c676d70b9ccf38aca82ac0d64a9.tar.bz2
bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015)
Set MemoryError when appropriate, add missing failure checks, and fix some potential leaks.
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/winconsoleio.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c
index 824690f..dd0997a 100644
--- a/Modules/_io/winconsoleio.c
+++ b/Modules/_io/winconsoleio.c
@@ -816,11 +816,13 @@ _io__WindowsConsoleIO_readall_impl(winconsoleio *self)
}
bufsize = newsize;
- buf = PyMem_Realloc(buf, (bufsize + 1) * sizeof(wchar_t));
- if (!buf) {
+ wchar_t *tmp = PyMem_Realloc(buf,
+ (bufsize + 1) * sizeof(wchar_t));
+ if (tmp == NULL) {
PyMem_Free(buf);
return NULL;
}
+ buf = tmp;
}
subbuf = read_console_w(self->handle, bufsize - len, &n);