]> granicus.if.org Git - python/commitdiff
Make sure the malloc'ed string has space for the null byte.
authorBrett Cannon <bcannon@gmail.com>
Sun, 21 Oct 2007 02:45:33 +0000 (02:45 +0000)
committerBrett Cannon <bcannon@gmail.com>
Sun, 21 Oct 2007 02:45:33 +0000 (02:45 +0000)
Parser/tokenizer.c

index c86fe7ea18b0ea2ce3a39c0c17d4e7971ccb1029..8c24cf28decee8ba045798d14fa5dd75414cf9ce 100644 (file)
@@ -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);