diff options
author | Zackery Spytz <zspytz@gmail.com> | 2018-12-07 10:11:30 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-12-07 10:11:30 (GMT) |
commit | 4c49da0cb7434c676d70b9ccf38aca82ac0d64a9 (patch) | |
tree | aae3660f9a5bc462830107cf2311b2557898e268 /Modules/_io | |
parent | 3a521f0b6167628f975c773b56c7daf8d33d6f40 (diff) | |
download | cpython-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.c | 6 |
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); |