From: Brett Cannon Date: Sun, 21 Oct 2007 02:45:33 +0000 (+0000) Subject: Make sure the malloc'ed string has space for the null byte. X-Git-Tag: v3.0a2~299 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c2954e5273520031d3debfac8c668b9e611303b3;p=python Make sure the malloc'ed string has space for the null byte. --- diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index c86fe7ea18..8c24cf28de 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -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);