Commit c2954e52 authored by Brett Cannon's avatar Brett Cannon

Make sure the malloc'ed string has space for the null byte.

parent e453989f
...@@ -1631,7 +1631,7 @@ PyTokenizer_FindEncoding(FILE *fp) { ...@@ -1631,7 +1631,7 @@ PyTokenizer_FindEncoding(FILE *fp) {
lseek(fileno(fp), 0, 0); lseek(fileno(fp), 0, 0);
if (tok->encoding) { if (tok->encoding) {
encoding = (char *)PyMem_MALLOC(strlen(tok->encoding)); encoding = (char *)PyMem_MALLOC(strlen(tok->encoding) + 1);
strcpy(encoding, tok->encoding); strcpy(encoding, tok->encoding);
} }
PyTokenizer_Free(tok); PyTokenizer_Free(tok);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment