[Python-3000-checkins] r58575 - python/branches/py3k/Parser/tokenizer.c

brett.cannon python-3000-checkins at python.org
Sun Oct 21 04:45:33 CEST 2007


Author: brett.cannon
Date: Sun Oct 21 04:45:33 2007
New Revision: 58575

Modified:
   python/branches/py3k/Parser/tokenizer.c
Log:
Make sure the malloc'ed string has space for the null byte.


Modified: python/branches/py3k/Parser/tokenizer.c
==============================================================================
--- python/branches/py3k/Parser/tokenizer.c	(original)
+++ python/branches/py3k/Parser/tokenizer.c	Sun Oct 21 04:45:33 2007
@@ -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);


More information about the Python-3000-checkins mailing list