Make sure the malloc'ed string has space for the null byte.
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index c86fe7e..8c24cf2 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -1631,7 +1631,7 @@
 	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);