mirror of https://github.com/python/cpython
Make sure the malloc'ed string has space for the null byte.
This commit is contained in:
parent
e453989f2e
commit
c2954e5273
|
@ -1631,7 +1631,7 @@ PyTokenizer_FindEncoding(FILE *fp) {
|
|||
lseek(fileno(fp), 0, 0);
|
||||
|
||||
if (tok->encoding) {
|
||||
encoding = (char *)PyMem_MALLOC(strlen(tok->encoding));
|
||||
encoding = (char *)PyMem_MALLOC(strlen(tok->encoding) + 1);
|
||||
strcpy(encoding, tok->encoding);
|
||||
}
|
||||
PyTokenizer_Free(tok);
|
||||
|
|
Loading…
Reference in New Issue