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.
This commit is contained in:
Zackery Spytz 2018-12-07 03:11:30 -07:00 committed by Serhiy Storchaka
parent 3a521f0b61
commit 4c49da0cb7
17 changed files with 113 additions and 27 deletions

View file

@ -953,6 +953,11 @@ tok_nextc(struct tok_state *tok)
buflen = PyBytes_GET_SIZE(u);
buf = PyBytes_AS_STRING(u);
newtok = PyMem_MALLOC(buflen+1);
if (newtok == NULL) {
Py_DECREF(u);
tok->done = E_NOMEM;
return EOF;
}
strcpy(newtok, buf);
Py_DECREF(u);
}