Mercurial > cpython-lru_cache-weakref
diff Parser/tokenizer.c @ 49020:3fa066d2a397
#3773: Check for errors around the use of PyTokenizer_FindEncoding().
reviewed by Brett Cannon.
| author | Amaury Forgeot d'Arc <amauryfa@gmail.com> |
|---|---|
| date | Thu, 04 Sep 2008 22:34:09 +0000 |
| parents | 45c43808979e |
| children | 6b04bc42baa5 |
line wrap: on
line diff
--- a/Parser/tokenizer.c Thu Sep 04 21:32:09 2008 +0000 +++ b/Parser/tokenizer.c Thu Sep 04 22:34:09 2008 +0000 @@ -1610,7 +1610,10 @@ fclose(fp); if (tok->encoding) { encoding = (char *)PyMem_MALLOC(strlen(tok->encoding) + 1); - strcpy(encoding, tok->encoding); + if (encoding) + strcpy(encoding, tok->encoding); + else + PyErr_NoMemory(); } PyTokenizer_Free(tok); return encoding;
